Skip to content
Discussion options

You must be logged in to vote

Hi, i decide to manipulate the data inside options key, so it look like this

CRUD::addfield([  
    'label'     => "Kelas",
    'type'      => 'select',
    'name'      => 'school_classroom_config_id',
    'entity'    => 'SchoolClassroomConfig',
    'model'     => "App\Models\SchoolClassroomConfig",
    'attribute' => 'classroom',
    'allows_null'     => false,
    'options'   => (function ($query) use($schoolId) {
        $query = $query->with('classroom')->whereIn('school_id', $schoolId)->get();
          foreach ($query as $key => $value) {
              $value->classroom_name = $value->classroom->classroom_name;
          }
          return($query);
    }),
]);

then I achieve what I …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@christmex
Comment options

Answer selected by christmex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant