restore composer.json, add mysqli extension
This commit is contained in:
47
app/Http/Requests/Dashboard/UsefulInfoRequest/Store.php
Executable file
47
app/Http/Requests/Dashboard/UsefulInfoRequest/Store.php
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Dashboard\UsefulInfoRequest;
|
||||
|
||||
use App\Models\UsefulInfo;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class Store extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name_uz' => 'required|string',
|
||||
'name_ru' => 'required|string',
|
||||
'image' => 'required|image',
|
||||
'position' => 'nullable|integer'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getName(): array
|
||||
{
|
||||
return [
|
||||
'uz' => $this->get('name_uz'),
|
||||
'ru' => $this->get('name_ru')
|
||||
];
|
||||
}
|
||||
|
||||
public function getPosition(): int|null
|
||||
{
|
||||
if ($this->position) {
|
||||
return $this->get('position');
|
||||
} else {
|
||||
if (UsefulInfo::count() === 0) {
|
||||
return 0;
|
||||
}
|
||||
return UsefulInfo::max('position') + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user