loan orders

This commit is contained in:
2024-09-23 23:39:08 +05:00
parent 2b3d6fd5da
commit ace16087a7
10 changed files with 543 additions and 153 deletions

View File

@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
use App\Models\Order\Loan\LoanOrder;
use App\Modules\LoanOrder\Controllers\Requests\LoanOrderStoreRequest;
use App\Modules\LoanOrder\Controllers\Resources\LoanOrderIndexResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class LoanOrderController extends Controller
@@ -13,7 +14,7 @@ class LoanOrderController extends Controller
/**
* LIST* Loan orders.
*/
public function index(Request $request)
public function index(Request $request): JsonResponse
{
return response()->json(LoanOrderIndexResource::collection(
LoanOrder::query()->where('user_id', auth()->id())->paginate()

View File

@@ -13,6 +13,7 @@ use App\Repos\System\Nova\NovaRepo;
use App\Repos\System\Settings\Legal\PassportRepo;
use App\Repos\System\Settings\Location\RegionRepo;
use Ebess\AdvancedNovaMediaLibrary\Fields\Files;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use Laravel\Nova\Fields\Badge;
@@ -60,6 +61,27 @@ class NovaVisaMasterPaymentOrder extends Resource
*/
public static $with = ['branch'];
/**
* Indicates whether the resource should automatically poll for new resources.
*
* @var bool
*/
public static $polling = true;
/**
* The interval at which Nova should poll for new resources.
*
* @var int
*/
public static $pollingInterval = 120;
/**
* Indicates whether to show the polling toggle button inside Nova.
*
* @var bool
*/
public static $showPollingToggle = true;
/**
* Get the displayable label of the resource.
*/
@@ -84,6 +106,27 @@ class NovaVisaMasterPaymentOrder extends Resource
);
}
/**
* Build an "index" query for the given resource.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public static function indexQuery(NovaRequest $request, mixed $query): Builder
{
$user = $request->user();
if ($user->isAdmin()) {
return $query;
}
if ($user->isOperator()) {
return $query->whereIn('branch_id', $user->branches()->pluck('branches.id'));
}
return $query->where('user_id', $request->user()->id);
}
/**
* After resource created
*