migrate to gtea from bistbucket
This commit is contained in:
34
app/Models/Blog.php
Normal file
34
app/Models/Blog.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user