Laravel - some useful tips

May 26, 2016

php artisan migrate not working

Added new migrations and running php artisan migrate not working, then try running the following artisan command. Also this works for any env related config changes.

php artisan config:cache
php artisan migrate

Still not working, then try composer auto load.

php artisan cache:clear
composer dump-autoload
php artisan migrate

Fixing unknown column ‘updated_at’ in ‘field list’.

This happens because Laravel assumes that you want to use the updated_at and created_at timestamps for your models. So it also assumes that they exist in the database. You can either create the two columns or disable timestamps for your model by adding

public $timestamps = false;

Getting the request input in Laravel views

app('request')->input('submit')

Listing all the Sessions in Laravel

Session::get(null)

Added new views and getting views not found error, then try running the following artisan command.

php artisan config:cache

Clearing all the caches

php artisan cache:clear
php artisan config:cache
php artisan route:cache
php artisan route:clear
php artisan optimize --force
composer dumpautoload -o