mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-11 01:11:07 +03:30
52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use App\Models\TestResult;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
|
class StoreTestResultRequest extends FormRequest
|
|
{
|
|
public function authorize()
|
|
{
|
|
if ($this->method() == 'POST') {
|
|
return auth('api')->check() && auth('api')->user()->can('store', TestResult::class);
|
|
} else {
|
|
$TestResult = $this->route('TestResult');
|
|
return auth('api')->check() && $TestResult && auth('api')->user()->can('update', $TestResult);
|
|
}
|
|
}
|
|
|
|
public function rules()
|
|
{
|
|
switch ($this->method()) {
|
|
case 'POST': {
|
|
return [
|
|
// 'device_id' => 'required',
|
|
// 'cycle_number' => 'required',
|
|
'test_type_id' => 'required|numeric|exists:test_types,id',
|
|
'result' => 'required',
|
|
];
|
|
break;
|
|
}
|
|
case 'PUT':
|
|
case 'PATCH': {
|
|
// $TestResult = $this->route('TestResult');
|
|
return [
|
|
// 'device_id' => 'required',
|
|
// 'cycle_number' => 'required',
|
|
'test_type_id' => 'required|numeric|exists:test_types,id',
|
|
'result' => 'required',
|
|
];
|
|
break;
|
|
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
}
|