File: /home/jubaroyal/public_html/app/Models/Blog.php
<?php
namespace App\Models;
use App\Models\User;
use App\Models\BlogCategory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Blog extends Model
{
use HasFactory, SoftDeletes;
protected $guarded = [];
public function createdBy(){
return $this->belongsTo(User::class, 'created_by')->withDefault(); // a next of kin belongs to a candidate
}
public function updatedBy(){
return $this->belongsTo(User::class, 'updated_by')->withDefault(); // a next of kin belongs to a candidate
}
public function blogCategory(){
return $this->belongsTo(BlogCategory::class, 'blog_category_id')->withDefault();
}
}