Lae/app/Http/Requests/User/WorkOrder/WorkOrderRequest.php

45 lines
917 B
PHP
Raw Normal View History

2022-08-15 11:10:51 +00:00
<?php
2022-08-15 14:29:57 +00:00
namespace App\Http\Requests\User\WorkOrder;
2022-08-15 11:10:51 +00:00
2022-08-15 14:29:57 +00:00
use App\Models\WorkOrder\WorkOrder;
2022-11-08 13:01:43 +00:00
use Illuminate\Foundation\Http\FormRequest;
2022-08-15 11:10:51 +00:00
2022-11-06 14:57:01 +00:00
class WorkOrderRequest extends FormRequest
2022-08-15 11:10:51 +00:00
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
2022-09-08 16:12:02 +00:00
public function authorize(): bool
2022-08-15 11:10:51 +00:00
{
2022-08-15 14:29:57 +00:00
2022-09-08 16:12:02 +00:00
$work_order = $this->route('workOrder');
2022-08-15 14:29:57 +00:00
// if work_order is model
if ($work_order instanceof WorkOrder) {
$work_order_id = $work_order->id;
} else {
$work_order_id = $work_order;
}
2022-11-06 11:28:22 +00:00
return WorkOrder::where('user_id', auth()->id())->where('id', $work_order_id)->exists();
2022-08-15 14:29:57 +00:00
2022-08-15 11:10:51 +00:00
return false;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
2022-09-08 16:12:02 +00:00
public function rules(): array
2022-08-15 11:10:51 +00:00
{
return [
//
];
}
}