ldc-legaulois/app/Models/Label.php
2022-02-10 16:14:58 +01:00

29 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');
}
}