feat: implement admin login form request
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class authLoginPostRequest 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, ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'username' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'alpha_num',
|
||||||
|
'min:2',
|
||||||
|
'max:32'
|
||||||
|
],
|
||||||
|
'password' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'min:8',
|
||||||
|
'max:150'
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,4 +25,23 @@ if (!function_exists('getFileUrl')) {
|
|||||||
|
|
||||||
return asset('storage/' . $file->path);
|
return asset('storage/' . $file->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!function_exists('activeAdminSidebar')) {
|
||||||
|
|
||||||
|
function activeAdminSidebar(string|array $routeNames): string
|
||||||
|
{
|
||||||
|
|
||||||
|
$currentRouteName = \Illuminate\Support\Facades\Route::currentRouteName();
|
||||||
|
|
||||||
|
if (is_string($routeNames)) {
|
||||||
|
$routeNames = [$routeNames];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array($currentRouteName, $routeNames)) {
|
||||||
|
return 'active';
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user