%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/geotechnics/api/app/Models/
Upload File :
Create Path :
Current File : /var/www/html/geotechnics/api/app/Models/Category.php

<?php

namespace App\Models;

/**
 * @property integer id
 * @property string code
 * @property string description
 * @property boolean is_enabled
 */
class Category extends BaseModel
{
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'code',
        'description',
        'is_enabled',
    ];

    protected $casts = [
        'code'        => 'string',
        'description' => 'string',
        'is_enabled'  => 'boolean',
    ];

    public function enable()
    {
        $this->is_enabled = true;
        $this->save();
        return $this;
    }

    public function disable()
    {
        $this->is_enabled = false;
        $this->save();
        return $this;
    }

    public function canDelete()
    {
        return $this->services()
                    ->count() === 0;
    }

    public function services()
    {
        return $this->hasMany(Service::class);
    }

}

Zerion Mini Shell 1.0