1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace App\Models;
- use App\Casts\Htmlspecialchar;
- use App\Casts\Json;
- use DateTimeInterface;
- use Illuminate\Database\Eloquent\Factories\HasFactory;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\SoftDeletes;
- class Project extends Model
- {
- use HasFactory,SoftDeletes;
- protected $table = 'js_project';
- // protected array $dates = ['delete_time'];
- const CREATED_AT = 'create_time';
- const UPDATED_AT = 'update_time';
- // 自定义软删除字段 默认 deleted_at
- const DELETED_AT = 'delete_time';
- protected $dateFormat = 'U';
- protected $fillable = ['name','icon','banner','content','price','order_price','minute','brief','is_show'];
- protected $hidden = [
- //
- ];
- protected $casts = [
- // 'create_time' => 'datetime',
- // 'password' => 'hashed',
- 'banner' => Json::class,
- 'content' => Htmlspecialchar::class
- ];
- protected function serializeDate(DateTimeInterface $date): string
- {
- return $date->format('Y-m-d H:i:s');
- }
- public function category()
- {
- return $this->hasMany(ProjectCategory::class,'project_id','id');
- }
- }
|