ldc-legaulois/app/Models/Label.php

30 lines
565 B
PHP
Raw Normal View History

2021-11-16 16:00:47 +01:00
<?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');
}
}