Category: PHP

How do I insert sample user into Laravel MySQL?

  1. Execute the following command to create UsersTableSeeder.php file.
    php artisan make:seeder UsersTableSeeder
  2. Then open UsersTableSeeder.php file and update it with the user login details.
    <?php
    namespace Database\Seeders;
    use Illuminate\Database\Seeder;
    use DB;
    class UsersTablesSeeder extends Seeder
    {
        /**
         * Run the database seeds.
         *
         * @return void
         */
        public function run()
        {
            DB::table(‘users’)->insert([
                                                 ‘name’ => ‘admin’,
                                                 ’email’ => ‘admin@email.com’,
                                                 ‘password’ => bcrypt(‘Admin@123’)
                                  ]);
        }
    }
    ?>
  3. Execute the following command to execute the seed file and create users to the database.
    php artisan db:seed –class=”UsersTablesSeeder

If you have any doubts comment here.

What is the server requirements for Laravel 7+?

The Laravel framework has a few system requirements. You can find the list of server requirements below

  • PHP >= 7.2.5
  • BCMath PHP Extension
  • Ctype PHP Extension
  • Fileinfo PHP extension
  • JSON PHP Extension
  • Mbstring PHP Extension
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension

What is SQL? What are the types available in SQL?

Structured Query Language, or SQL, is the standard language used to communicate with a database, and or change records and user privileges, and perform queries. The Language, which became an ANSI standard in 1989, is currently used by almost all of today’s commercial RDBMS.

Types of SQL

  • Data Definition Language(DDL)
  • Data Manipulation Language(DML)
  • Data Control Language(DCL)

How to Change “Return to Shop” Button text in WooCommerce

In this article, I will show you How to Change “Return to Shop” Button text in WooCommerce.

Copy below code and paste into theme function.php file.

add_filter( 'gettext', 'change_woocommerce_return_to_shop_text', 20, 3 );
function change_woocommerce_return_to_shop_text( $translated_text, $text, $domain ) {
    switch ( $translated_text ) {
        case 'Return to shop' :
        $translated_text = __( 'Return to Store', 'woocommerce' );
        break;
    }
    return $translated_text;
}

Have any doubt, then comment here!

What is the difference between BLOB AND TEXT in MySQL?

A BLOB is a binary large object that can hold a variable amount of data. There are four types of BLOB

  • TINYBLOB
  • BLOB
  • MEDIUMBLOB and
  • LONGBLOB

They all differ only in the maximum length of the values they can hold.

A TEXT is a case-insensitive BLOB. The four TEXT types

  • TINYTEXT
  • TEXT
  • MEDIUMTEXT and
  • LONGTEXT

They all correspond to the four BLOB types and have the same maximum lengths and storage requirements.

The only difference between BLOB and TEXT types is that sorting and comparison is performed in case-sensitive for BLOB values and case-insensitive for TEXT values.