<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model;

class ServiceCategory extends Model
{
    use HasDateTimeFormatter;
    use SoftDeletes;

    protected $table = 'service_category';
    // 定义一对多关系
    public function services()
    {
        return $this->hasMany(ServiceProject::class, 'category_id');
    }

    // 排序逻辑
    public function setSortAttribute($value)
    {
        $this->attributes['sort'] = $value;
    }
}
