12345678910111213141516171819202122232425262728293031323334 |
- <?php
- namespace App\Models;
- use Dcat\Admin\Traits\HasDateTimeFormatter;
- use Illuminate\Database\Eloquent\SoftDeletes;
- use Illuminate\Database\Eloquent\Model;
- class LibraryBook extends Model
- {
- use HasDateTimeFormatter;
- use SoftDeletes;
- protected $table = 'library_books';
- protected $guarded = [];
- const statusMaps = [
- 0 => '禁用',
- 1 => '正常',
- ];
- public function category()
- {
- return $this->belongsTo(LibraryCategory::class);
- }
- public function getCoverPathUrlAttribute()
- {
- if (array_key_exists('cover_path', $this->attributes)) return path_to_url($this->attributes['cover_path'], config('admin.upload.disk'));
- return '';
- }
- }
|