Files
kulakpos_web/app/Models/Blog.php

35 lines
736 B
PHP
Raw Normal View History

2026-03-15 17:08:23 +07:00
<?php
namespace App\Models;
use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Blog extends Model
{
use HasFactory;
protected $fillable = ['user_id', 'title', 'slug', 'image', 'status', 'descriptions', 'tags', 'meta'];
protected $casts = [
'user_id' => 'integer',
'tags' => 'json',
'meta' => 'json',
'status' => 'integer'
];
public function user()
{
return $this->belongsTo(User::class, 'user_id');
}
protected static function boot()
{
parent::boot();
static::creating(function ($blog) {
$blog->slug = Str::slug($blog->title);
});
}
}