Category Archives: Laravel

Dealing with databases in Laravel vol 2 – error SQLSTATE[42000]

Error: [Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table users add unique users_email_unique(email)) [PDOException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes Solution:
  • In your Laravel folder go to app - Providers - AppServiceProvider.php
  • Add use Illuminate\Support\Facades\Schema; after use Illuminate\Support\ServiceProvider; If you don't do it you'll get next error: [Symfony\Component\Debug\Exception\FatalErrorException] Class 'App\Providers\Schema' not found
  • Inside boot function add next line: Schema::defaultStringLength(191);
Now your AppServiceProvider.php file should look like this:





Find solution from laravel-news.com. 

					

Dealing with databases in Laravel vol 1

Before running
php artisan migrate
don't forget to make real database on server. Let's name it blogdb. In .env file following changes needed to be done:
  • DB_DATABASE=homestead rename as DB_DATABASE=blogdb
  • DB_USERNAME=homestead rename as DB_USERNAME=yourusername
  • DB_PASSWORD=secret rename as DB_PASSWORD=yourpassword

Auth in Laravel

For logging system in Laravel I can do this: 1. Win logo on keyboard + R. 2. Type cmd. 3. Go to my Laravel's folder (cd + folder name/or cd.. for moving directory up ) 4. php artisan make:auth