Lae/app/Http/Requests/Remote/WorkOrderRequest.php
2022-09-09 00:12:02 +08:00

41 lines
877 B
PHP

<?php
namespace App\Http\Requests\Remote;
use App\Models\WorkOrder\WorkOrder;
use Anik\Form\FormRequest;
class WorkOrderRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize(): bool
{
$work_order = $this->route('workOrder');
// if work_order is model
if ($work_order instanceof WorkOrder) {
$work_order_id = $work_order->id;
} else {
$work_order_id = $work_order;
}
return WorkOrder::where('id', $work_order_id)->where('module_id', auth('remote')->id())->exists();
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules(): array
{
return [
//
];
}
}