Step #1 Create the Migration php artisan make:migration add_middlename_to_users_table –table=users Step #2 Copy the below function and replace up function and down function. public function up() { Schema::table(‘users’, function($table) { $table->string(‘middlename’); }); } and also don’t forget to add the roll back option public function down() { Schema::table(‘users’, function($table) { $table->dropColumn(‘middlename’); }); } Step #3 […]
How To Save All Docker Images And Copy/Move To Another Host?
Follow the below steps to export all docker images and import to another system. Step #1 Export or save all images to one tar file. docker save $(docker images –format ‘{{.Repository}}:{{.Tag}}’) -o allfilestoone.tar Step #2 From the other host load to docker docker load -i allfilestoone.tar
How to run specific migration in Laravel?
Use the below command to run only a selected migration. php artisan migrate –path=/database/migrations/migation_file.php
Truncate a table in Laravel
Using Eloquent User::truncate(); Using DB records DB::table(‘users’)->truncate();
How to set foreign key check to zero in Laravel?
DB::statement(‘SET FOREIGN_KEY_CHECKS=0’); Schema::drop(‘your table name’); ………….. ………….. DB::statement(‘SET FOREIGN_KEY_CHECKS=1’); Tested in Laravel 8.x
Start a PHP a server on Mac OS X
php -S localhost:9000
Get/Print raw SQL in Larvel?
DB::enableQueryLog(); // Enabling the query log // Write your Eloquent query here dd(DB::getQueryLog()); // Show the querry
How to enable Word wrap in PHPStorm?
If you want to enable the text word wrapped in PHPStorm, go to
How to yield a default value in Laravel Blade?
It’s very easy to yield a default value in Laravel blade, just follow the below code
How To Include A Partial Template in Blade
How to include blade template when it inside another blade template. Just use the below snippet in your blade code. <div class=”header”> @include(‘path/to/partial’) </div>
How to list directories with size in Linux
Run the following to get the size of the directories in Linux. This is the short version of A bit of explanation for the commands. du : Disk Usage -s : Display a summary for each specified file -h : Short of human readable.
mysqldump – Taking MySQL dump from another machine
When prompts password please input password.
How to get the current date and time in PHP?
Most simple format This will be returning based on the default server timezone. If you want to change the timezone and generate the time as per the timezone, use the below code. Call the date function, it will return according to the timezone.
How to check the version of Ubuntu via SSH?
Just run the below command in the command line Output In other way you can run the below command too Output
How to concatenate set of results in MySQL?
In this post we are discussing about how to join the results from a query with a comma seperate or a pipe whatever. Suppose I have a users table, and I need to show all this users name in a comman seperated format in one single line. name John Doe Kasper Jen The diresired output […]
Copy & Rename a File in a Directory – PHP
You can use PHP script to Copy & Rename a File in a Directory.We use copy PHP function to do this.
Laravel Eloquent – How to get the row count?
This simple code will give you the row count in Laravel Eloquent.
CSS border-radius property
Give a rounded corners to any element using the CSS border-radius property.
How to insert multiple rows in Laravel 5?
You can bulk insert to database table using either Eloquent or query builder in Laravel.