Skip to content

respect eager loading  #4

Description

@ibrahem-kamal

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions