-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
106 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests\Bom; | ||
|
||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class StoreBomRequest extends FormRequest | ||
{ | ||
/** | ||
* Determine if the user is authorized to make this request. | ||
*/ | ||
public function authorize(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string> | ||
*/ | ||
public function rules(): array | ||
{ | ||
return [ | ||
'qty' => 'required|numeric', | ||
'item' => 'required|string', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests\Bom; | ||
|
||
use Illuminate\Validation\Rule; | ||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class UpdateBomRequest extends FormRequest | ||
{ | ||
/** | ||
* Determine if the user is authorized to make this request. | ||
*/ | ||
public function authorize(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string> | ||
*/ | ||
public function rules(): array | ||
{ | ||
# update HTTP method used | ||
$method = $this->method(); | ||
|
||
if ($method == 'PUT') { | ||
return [ | ||
'qty' => 'required|numeric', | ||
'item' => [ | ||
'required', | ||
'string', | ||
Rule::unique('boms', 'item')->ignore($this->input('item'), 'item') | ||
], | ||
]; | ||
} else { | ||
return [ | ||
'qty' => 'sometimes|required|numeric', | ||
'item' => [ | ||
'sometimes', | ||
'required', | ||
'string', | ||
Rule::unique('boms', 'item')->ignore($this->input('item'), 'item') | ||
], | ||
]; | ||
} | ||
} | ||
} |