Closed dmarcos89 closed 2 months ago
Hey @dmarcos89
I'm using the following code in my project to handle it:
//PaymentCrudController
CRUD::column('booking_travel_datetime')
->type('select')
->entity('booking')
->model(\App\Models\Booking::class)
->label('Travel DateTime')
->attribute('booking_travel_datetime')
->orderable(true)
->orderLogic(function ($query, $column, $columnDirection) {
return $query->leftJoin('bookings', 'bookings.id', '=', 'payments.booking_id')
->orderBy('bookings.booking_travel_datetime', $columnDirection)->select('payments.*');
});
class Payment extends Model
{
public function booking()
{
return $this->belongsTo(\App\Models\Booking::class, 'booking_id');
}
}
I think ->select('schedules.*')
can help!
Thank you so much @karandatwani92, that fixed it! 🥳
Bug report
What I did
Applying a custom order for a column:
What I expected to happen
Order the table using the selected column.
What happened
select *...
, the id from the left joined table is being used instead of the main one.Is this expected? Any way to avoid this behaviour?
What I've already tried to fix it
Not sure what else to try...
Is it a bug in the latest version of Backpack?
After I run
composer update backpack/crud
the bug... is it still there?Yes
Backpack, Laravel, PHP, DB version