wip
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
7
app/Repos/System/Location/ProvinceRepo.php
Normal file
7
app/Repos/System/Location/ProvinceRepo.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repos\System\Location;
|
||||
|
||||
class ProvinceRepo
|
||||
{
|
||||
}
|
||||
@@ -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