wip
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Repos\System\Nova;
|
||||
|
||||
use App\Models\System\Location\Province;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Laravel\Nova\Events\ServingNova;
|
||||
@@ -41,4 +42,19 @@ class NovaRepo
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Depends on region
|
||||
*/
|
||||
public static function dependsOnRegion(string $attribute = 'region', string $model = Province::class): Closure
|
||||
{
|
||||
return function ($field, $request, $formData) use ($attribute, $model) {
|
||||
info($formData->{$attribute});
|
||||
$field->options(
|
||||
$formData->{$attribute}
|
||||
? $model::where('region', $formData->{$attribute})->pluck('name', 'id')
|
||||
: []
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user