Laravel 5.4 – Validation with Regex [duplicate]

Your rule is well done BUT you need to know, specify validation rules with regex separated by pipeline can lead to undesired behavior. The proper way to define a validation rule should be: $this->validate(request(), [ ‘projectName’ => array( ‘required’, ‘regex:/(^([a-zA-Z]+)(\d+)?$)/u’ ) ]; You can read on the official docs: regex:pattern The field under validation must … Read more

Laravel 5.4 Disable Register Route

The code: Auth::routes(); its a shorcut for this collection of routes: // Authentication Routes… Route::get(‘login’, ‘Auth\LoginController@showLoginForm’)->name(‘login’); Route::post(‘login’, ‘Auth\LoginController@login’); Route::post(‘logout’, ‘Auth\LoginController@logout’)->name(‘logout’); // Registration Routes… Route::get(‘register’, ‘Auth\RegisterController@showRegistrationForm’)->name(‘register’); Route::post(‘register’, ‘Auth\RegisterController@register’); // Password Reset Routes… Route::get(‘password/reset’, ‘Auth\ForgotPasswordController@showLinkRequestForm’)->name(‘password.request’); Route::post(‘password/email’, ‘Auth\ForgotPasswordController@sendResetLinkEmail’)->name(‘password.email’); Route::get(‘password/reset/{token}’, ‘Auth\ResetPasswordController@showResetForm’)->name(‘password.reset’); Route::post(‘password/reset’, ‘Auth\ResetPasswordController@reset’); So you can substitute the first with the list of routes and comment out any route … Read more

How to logout and redirect to login page using Laravel 5.4?

In your web.php (routes): add: Route::get(‘logout’, ‘\App\Http\Controllers\Auth\LoginController@logout’); In your LoginController.php add: public function logout(Request $request) { Auth::logout(); return redirect(‘/login’); } Also, in the top of LoginController.php, after namespace add: use Auth; Now, you are able to logout using yourdomain.com/logout URL or if you have created logout button, add href to /logout

Laravel Migration Error: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

According to the official Laravel 7.x documentation, you can solve this quite easily. Update your /app/Providers/AppServiceProvider.php to contain: use Illuminate\Support\Facades\Schema; /** * Bootstrap any application services. * * @return void */ public function boot() { Schema::defaultStringLength(191); } Alternatively, you may enable the innodb_large_prefix option for your database. Refer to your database’s documentation for instructions on … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)