This commit is contained in:
2023-11-28 12:40:49 +05:00
parent b45cec0200
commit dab7cc0069
16 changed files with 215 additions and 58 deletions

View File

@@ -0,0 +1,7 @@
<?php
namespace App\Repos\System\Location;
class ProvinceRepo
{
}

View File

@@ -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')
: []
);
};
}
}