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

@@ -1,6 +1,6 @@
<?php
namespace App\Repos\Order\Loan;
namespace App\Repos\Branch;
use App\Models\Branch\Branch;
use Illuminate\Support\Collection;
@@ -9,6 +9,7 @@ class BranchRepo
{
/**
* Model
*
* @var App\Models\Branch\Branch
*/
protected $model;
@@ -16,7 +17,7 @@ class BranchRepo
/**
* New Branch Repo
*/
public function __construct()
public function __construct()
{
$this->model = Branch::class;
$this->query = $this->model::query();
@@ -54,6 +55,6 @@ class BranchRepo
*/
public static function values(): Collection|array
{
return static::make()->pluck('name', 'id');
return static::make()->query()->pluck('name', 'id');
}
}

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