mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-28 12:11:08 -04:00
v5.0.0 update
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
namespace Crater\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class NotesRequest extends FormRequest
|
||||
{
|
||||
@ -23,10 +24,40 @@ class NotesRequest extends FormRequest
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'type' => ['required'],
|
||||
'name' => ['required'],
|
||||
'notes' => ['required'],
|
||||
$rules = [
|
||||
'type' => [
|
||||
'required'
|
||||
],
|
||||
'name' => [
|
||||
'required',
|
||||
Rule::unique('notes')
|
||||
->where('company_id', $this->header('company'))
|
||||
->where('type', $this->type)
|
||||
],
|
||||
'notes' => [
|
||||
'required'
|
||||
],
|
||||
];
|
||||
|
||||
if ($this->isMethod('PUT')) {
|
||||
$rules['name'] = [
|
||||
'required',
|
||||
Rule::unique('notes')
|
||||
->ignore($this->route('note')->id)
|
||||
->where('type', $this->type)
|
||||
->where('company_id', $this->header('company'))
|
||||
];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function getNotesPayload()
|
||||
{
|
||||
return collect($this->validated())
|
||||
->merge([
|
||||
'company_id' => $this->header('company')
|
||||
])
|
||||
->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user