for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Http\Requests\Denomination;
use App\Infrastructure\Foundation\Http\FormRequest;
use App\Models\Denomination;
use Illuminate\Support\Facades\Storage;
class UpdateRequest extends FormRequest
{
/**
* {@inheritDoc}
*/
public function authorize()
return !is_null($this->user());
}
public function rules()
return [
//
];
public function attributes()
'name' => trans('Name'),
'value' => trans('Value'),
'type' => trans('Type'),
'quantity_per_bundle' => trans('Quantity Per Bundle'),
'minimum_order_bundle' => trans('Minimum Order Bundle'),
'maximum_order_bundle' => trans('Maximum Order Bundle'),
'image' => trans('Image'),
* Update the image file from the incoming request.
*
* @param string $key
* @return string|null
public function updateImage(string $key = 'image'): ?string
if (!$this->hasFile($key)) {
return null;
/** @var \App\Models\Denomination $model */
$model = $this->route('denomination');
if ($model->getRawOriginal('image') && $this->hasFile($key)) {
Storage::delete(Denomination::IMAGE_PATH . '/' . $model->getRawOriginal('image'));
$model->getRawOriginal('image')
array|mixed
concatenation
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
ignore-type
Storage::delete(Denomination::IMAGE_PATH . '/' . /** @scrutinizer ignore-type */ $model->getRawOriginal('image'));
$file = $this->file($key);
$file->storeAs(
Denomination::IMAGE_PATH,
$filename = ($this->input('value') . '.' . $file->getClientOriginalExtension())
);
return $filename;