- SQLSTATE[42000]: Syntax error or access violation: specified key was too long->This is due to old version (In 5.4 and 5.5) on mysql or mariadb. To fix that error, goto
app>providers>AppServiceProviders.php
. Inside boot()
method writeSchema::defaultStringLength(191);
And write after namespace
use Illuminate\Support\Facades\Schema;
- The page has expired due to inactivity: Refreshing the page could solve the problem. If refreshment cannot solve the problem then you might missed
csrf_token()
field in any form of that page.
- No such file or directory: Run the command
composer dump-autoload
- MassAssignmentException: Create $fillable in you model and give the key which will be filled.
- Foreign key constraint is incorrectly formed: You fault is: you have put
$table->references()->on()
inside Schema::create(){}
Your migration should be like below:
Schema::create('articles', function (Blueprint $table) {
$table->increments('id');
$table->string('body');
$table->timestamps();
});
// Add Foreign key
Schema::table('articles', function (Blueprint $table) {
$table->unsignedInteger('user_id');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
- errno: 121 “Duplicate key on write or update”: Carefully check names of the table in
Schema::table('is_it_correct?
‘){}
- Edit your applications’s database config file
config/database.php
In mysql
array, set strict => false
to disable MySQL’s strict mode
- nl2br: When anybody
Using app\Providers\AppServiceProvider
Add the following code to AppServiceProvider.php> boot function
Blade::setEchoFormat('nl2br(e(%s))');
and the namespace for it
use Illuminate\Support\Facades\Blade;
Now all new line will be replaced by <br/&gh;
including textarea during update. You can escape this text using three curly bracket as like below:
{{{ $your_variable }}}
NB: Be careful about cache.
- You can use nl2br in your blade
{{ nl2br(e($your_variable)) }}
'Class 'PayPal\Rest\ApiContext' not found'
Solution: Either the package is not installed correctly or composer dump-autoload need to run. If you have installed the paypal once, please install again (In my case, I installed once did not run).
- vendor/autoload.php failed to open stream laravel: This error occured after cloning my project from gitlab. To solve run the command below:
composer update --no-scripts
- Trying to get property 'id' of non-object .... in AppServiceProvider.php line 20: This error occured because you are logged out. Login again and problem solved.