Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

respect eager loading #4

Open
ibrahem-kamal opened this issue Aug 10, 2021 · 0 comments
Open

respect eager loading #4

ibrahem-kamal opened this issue Aug 10, 2021 · 0 comments

Comments

@ibrahem-kamal
Copy link

ibrahem-kamal commented Aug 10, 2021

if i have a searchable value and other records are chaining on it , in edit form the chained values are not presented in the request because the the main Chain::as is eager loaded : ex

      Chain::as('user', function () {
        return [
             SearchableSelect::make('User', 'user_id')->resource("users")
            ->rules('required')
           ->displayUsingLabels()
        ];
      }),
      Chain::with('user.user_id', function ($request) {
        if ($request->user_id) {
          return [
            Select::make('User Car', 'car_id')
              ->options(
                \App\UserCar::where('user_id', $request->user_id)->pluck('plate_number', 'id')->toArray()
              )
          ];
        }
        return [];
      }, 'car'),
      Chain::with('car.car_id', function ($request) {
        if ($request->car_id) {
          $car = \App\UserCar::find($request->car_id);
          return [
            Multiselect::make('Services')
              ->options(
                MaintenanceServiceVehicleModel::where('vehicle_model_id', $car->vehicle_model_id)->with('serviceType')->get()->mapWithKeys(function ($item) {
                  return [$item['id'] => $item['serviceType']['title_en']];
                })->toArray()
              ),
          ];
        }

        return [];
      }),

in this example , in the edit form , only the user_id are presented in the request and not the other fields

@ibrahem-kamal ibrahem-kamal changed the title respect lazy loading respect eager loading Aug 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant