I'm having an error trying to execute the source code below in my resource file
public function fields(Request $request)
{
$userid = "";
// pull hierarchy under this user's company
$userid = $request->get('viaResourceId');
$user_details = User::find($userid);
$company_id = $user_details->company_id;
$options = [];
$options = Hierarchy::where('company_id', '=', $company_id)->with('category')->get();
return [
ID::make()->sortable(),
NovaBelongsToDepend::make('Hierarchy')
->options($options),
NovaBelongsToDepend::make('Category')
->optionsResolve(function ($hierarchy) {
// Reduce the amount of unnecessary data sent
return $hierarchy->category()->get(['id', 'name']);
})
->dependsOn('Hierarchy'),
];
}
What i want is it will filter Category depending on the result in Hierarchy, The problem is when it tries to populate Category(executing another request in the backend part) $request->get('viaResourceId') becomes null and causes error. could anyone have a solution on this please?
I'm having an error trying to execute the source code below in my resource file
What i want is it will filter Category depending on the result in Hierarchy, The problem is when it tries to populate Category(executing another request in the backend part) $request->get('viaResourceId') becomes null and causes error. could anyone have a solution on this please?