30 lines
565 B
PHP
30 lines
565 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models;
|
||
|
|
|
||
|
|
use Illuminate\Support\Str;
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
|
||
|
|
class Label extends Model
|
||
|
|
{
|
||
|
|
protected $fillable = [
|
||
|
|
'name',
|
||
|
|
'status'
|
||
|
|
];
|
||
|
|
|
||
|
|
protected static function booted()
|
||
|
|
{
|
||
|
|
static::creating(function ($type) {
|
||
|
|
$type->slug = Str::slug($type->name);
|
||
|
|
});
|
||
|
|
static::updating(function ($type) {
|
||
|
|
$type->slug = Str::slug($type->name);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
public function products()
|
||
|
|
{
|
||
|
|
return $this->hasMany(Products::class, 'label_id');
|
||
|
|
}
|
||
|
|
}
|