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(AppModelsMasterCategoryStatus::class, 'category_status_id', 'id');
}
}
I got an error Requested unknown parameter 'categoryStatus.name'
question from:
https://stackoverflow.com/questions/65935649/laravel-datatable-service-using-with-relationship-different-name 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…