Posts

Showing posts from March, 2020

Update Laravel version 5.5 to 5.8

Image
Recently, I got a chance to update my current Laravel project version from 5.5. to 5.8. In this post, I will let you know how I achieved it. I decided to update them one by one and divided problem into three phases which are like:- Laravel 5.5 to Laravel 5.6. Laravel 5.6 to Laravel 5.7 Laravel 5.7 to Laravel 5.8 Laravel 5.5 to Laravel 5.6 First of all, I read update document guide of Laravel 5.6 check all changes for version 5.6. I also identify those packages which I am currently using and they need to update. After I make changes in my composer.json and these changes are following. "laravel/framework": "5.6.*"  "phpunit/phpunit": "^7.0", These changes depends on packages which I are including in my application and update. All requirements for Laravel 5.6 shown in Image. After update all changes in composer run composer update . After that i make some changes into my config folder these are following:- Remo

Write SQL queries in Laravel migration.

Image
Sometimes we need to write some manual SQL queries in Laravel migration . eg. I want to add a new field cast_the_vote in existing table users which have age of users. If age is greater than 18 then save true in cast_the_vote otherwise false in migration. So your migration file should looks like:- <?php use Illuminate\Support\Facades\ Schema ; use Illuminate\Database\Schema\ Blueprint ; use Illuminate\Database\Migrations\ Migration ; class ChangeUsersTable extends Migration { public function up () { Schema :: table ( 'users' , function ( Blueprint $table ) { $table -> boolean ( 'cast_the_vote' )-> default ( false ); }); $this -> upadateDB (); } public function down () { Schema :: table ( 'users' , function ( Blueprint $table ) { $table -> dropColumn ( 'cast_the_vote' ); }); }