refactor(transaction): menjadikan gambar menjadi opsional
This commit is contained in:
parent
e1dcfd4849
commit
3bfe048ce6
@ -65,7 +65,9 @@ public function store(TransactionRequest $request): RedirectResponse
|
||||
'service_id' => $validatedData['service'],
|
||||
'customer_id' => $customer ? $customer->id : $validatedData['customer'],
|
||||
]));
|
||||
$this->uploadAttachment($validatedData['image'], 'transactions', Transaction::class, $newTransaction->id);
|
||||
if (isset($validatedData['image'])) {
|
||||
$this->uploadAttachment($validatedData['image'], 'transactions', Transaction::class, $newTransaction->id, 'transaction');
|
||||
}
|
||||
});
|
||||
|
||||
notify()->success('Data berhasil ditambahkan', 'Berhasil');
|
||||
@ -95,7 +97,7 @@ public function update(Transaction $transaction, TransactionRequest $request): R
|
||||
'customer_id' => $validatedData['customer'],
|
||||
]));
|
||||
if (isset($validatedData['image'])) {
|
||||
$this->uploadAttachment($validatedData['image'], 'transactions', Transaction::class, $transaction->id);
|
||||
$this->uploadAttachment($validatedData['image'], 'transactions', Transaction::class, $transaction->id, 'transaction');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -28,8 +28,6 @@ protected function prepareForValidation(): void
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$isEdit = $this->isMethod('put');
|
||||
|
||||
return [
|
||||
'barber' => ['required', Rule::exists('users', 'id')],
|
||||
'service' => ['required', Rule::exists('services', 'id')],
|
||||
@ -37,9 +35,7 @@ public function rules(): array
|
||||
'price' => ['required', 'numeric', 'min:0', 'max:999999.99'],
|
||||
'discount' => ['required', 'numeric', 'min:0', 'max:999999.99'],
|
||||
'total' => ['required', 'numeric', 'min:0', 'max:999999.99'],
|
||||
'image' => $isEdit
|
||||
? ['nullable', 'image', 'mimes:jpeg,png,jpg,gif,svg', 'max:2048']
|
||||
: ['required', 'image', 'mimes:jpeg,png,jpg,gif,svg', 'max:2048'],
|
||||
'image' => ['nullable', 'image', 'mimes:jpeg,png,jpg,gif,svg', 'max:2048'],
|
||||
'payment_method' => ['required', Rule::in(['1', '2', '3'])],
|
||||
];
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@
|
||||
</div>
|
||||
<div class="col-lg-6 position-relative">
|
||||
<label class="form-label" for="image">Gambar
|
||||
<span class="form-span"><i>(.jpeg,.png,.jpg,.gif,.svg)</i></span>
|
||||
<span class="form-span"><i>(Opsional,.jpeg,.png,.jpg,.gif,.svg)</i></span>
|
||||
</label>
|
||||
<input name="image" class="form-control @error('image') is-invalid @enderror" id="image"
|
||||
type="file" value="{{ old('image') }}"
|
||||
|
||||
@ -105,7 +105,7 @@
|
||||
</div>
|
||||
<div class="col-lg-6 position-relative">
|
||||
<label class="form-label" for="image">Gambar
|
||||
<span class="form-span"><i>(.jpeg,.png,.jpg,.gif,.svg)</i></span>
|
||||
<span class="form-span"><i>(Opsional, .jpeg,.png,.jpg,.gif,.svg)</i></span>
|
||||
</label>
|
||||
<input name="image" class="form-control @error('image') is-invalid @enderror" id="image"
|
||||
type="file" value="{{ old('image') }}"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user