Well, first - You should provide Your solution a FormRequest
, which might be as the following:
namespace App\Http\Requests;
use Illuminate\Support\Facades\Auth;
/**
* Class UserRequest
* @package App\Http\Requests
*/
class UserRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return !Auth::check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'email' => 'required|unique:users|email_active:[email protected]|email_online:[email protected]',
'password' => 'required|string|between:4,40'
];
}
public function messages()
{
return [
'email.required' => 'Email is required',
'email.unique' => 'This Email is already in use',
'email.email_active' => 'This email is not active',
'email.email_online' => 'This email is online',
'password.required' => 'Password is required',
'password.between' => 'Password length should be between :min and :max characters'
];
}
}
email_active
and email_online
rules don't exist on the Laravel box. You should create them via php artisan make:rule EmailActiveRule
and php artisan make:rule EmailOnlineRule
.
Then, You need to extend Your rules by following this article.
Then, in the rules You need to check the records in the database via Repository
or Model
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community