release
This commit is contained in:
71
app/Http/Requests/LoginRequest.php
Normal file
71
app/Http/Requests/LoginRequest.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Contracts\Validation\Factory as ValidationFactory;
|
||||
|
||||
class LoginRequest 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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'username' => 'required',
|
||||
'password' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the needed authorization credentials from the request.
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function getCredentials()
|
||||
{
|
||||
// The form field for providing username or password
|
||||
// have name of "username", however, in order to support
|
||||
// logging users in with both (username and email)
|
||||
// we have to check if user has entered one or another
|
||||
$username = $this->get('username');
|
||||
|
||||
if ($this->isEmail($username)) {
|
||||
return [
|
||||
'email' => $username,
|
||||
'password' => $this->get('password')
|
||||
];
|
||||
}
|
||||
|
||||
return $this->only('username', 'password');
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate if provided parameter is valid email.
|
||||
*
|
||||
* @param $param
|
||||
* @return bool
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
private function isEmail($param)
|
||||
{
|
||||
$factory = $this->container->make(ValidationFactory::class);
|
||||
|
||||
return ! $factory->make(
|
||||
['username' => $param],
|
||||
['username' => 'email']
|
||||
)->fails();
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ProductApplicationRequest extends FormRequest
|
||||
{
|
||||
@ -24,8 +25,9 @@ class ProductApplicationRequest extends FormRequest
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$slug = request()->post('slug');
|
||||
return [
|
||||
'slug' => 'required|unique:product_applications,slug',
|
||||
'slug' => 'required|unique:product_applications,slug,'.$this->id.',id',
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ class ProductCatalogRequest extends FormRequest
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'slug' => 'required|unique:product_catalogs,slug',
|
||||
'slug' => 'required|unique:product_catalogs,slug,'.$this->id.',id',
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ class ProductRequest extends FormRequest
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// 'slug' => 'required|unique:products,slug',
|
||||
'slug' => 'required|unique:product_catalogs,slug,'.$this->id.',id',
|
||||
];
|
||||
}
|
||||
|
||||
|
33
app/Http/Requests/RegisterRequest.php
Normal file
33
app/Http/Requests/RegisterRequest.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class RegisterRequest 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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'email' => 'required|email:rfc,dns|unique:users,email',
|
||||
//'username' => 'required|unique:users,username',
|
||||
'password' => 'required|min:8',
|
||||
'password_confirmation' => 'required|same:password',
|
||||
'name' => 'required',
|
||||
'phone' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
@ -14,7 +14,8 @@ class SupportSaleRequest extends FormRequest
|
||||
public function authorize()
|
||||
{
|
||||
// only allow updates if the user is logged in
|
||||
return backpack_auth()->check();
|
||||
//return backpack_auth()->check();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,7 +14,8 @@ class SupportTechnicalRequest extends FormRequest
|
||||
public function authorize()
|
||||
{
|
||||
// only allow updates if the user is logged in
|
||||
return backpack_auth()->check();
|
||||
//return backpack_auth()->check();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user