I tried using 2 words method relationship. How i can implement the relationship in datatable service using ->with
?
In the query
method looks like this :
public function query(Pihak $model)
{
$model = Pihak::query()
->with(['categoryStatus'])
->where('client_id', $this->clientid);
return $this->applyScopes($model);
}
Which is has different name with database table (database table name for categoryStatus
is master_category_status
) and then i called it in column like this :
Column::make('categoryStatus')->data('categoryStatus.name')
->name('categoryStatus.name')
Here is it Pihak model
class Pihak extends Model
{
public $table = 'pihaks';
public function categoryStatus()
{
return $this->belongsTo(\App\Models\MasterCategoryStatus::class, 'category_status_id', 'id');
}
}
I got an error Requested unknown parameter 'categoryStatus.name'
I've found the solution. I don't know why it should be snake case method but i'm trying using the method with snake case method (category_status
) and it works