Post.php Model
created_by = Helper::admin_detail('id');
$model->updated_by = Helper::admin_detail('id');
// $model->created_by = 1;
// $model->updated_by = 2;
});
// create a event to happen on deleting
static::deleting(function ($model) {
$model->deleted_by = Helper::admin_detail('id');
});
static::updating(function ($model) {
//$user = Auth::user();
$model->updated_by = Helper::admin_detail('id');
});
}
public $table = 'news_post';
protected $fillable = ["title", "category_id", "news_body", "image"];
public function category()
{
return $this->hasOne('App\admin\Category', 'id', 'category_id')->select(['name', 'id']);
}
public function user()
{
return $this->hasOne('App\admin\Users', 'id', 'user_id')->select(['name', 'id']);
}
}
Comments
Post a Comment