Skip to main content

Laravel cmd commands

php artisan --version   -- check laravel version 
php artisan serve    -- to start laravel

php artisan route:list    -- to show all the routes as defined in web.php

php artisan make:controller TestController      --  to make new controller

php artisan make:controller MovieController --resource                 ->  use command to make new controller with all crud operations in it

php artisan make:migration create_books_table --create=books             -->  to create new table file in database/migrate folder

php artisan migrate   -->  to create tables in database of created files in migrate folder

php artisan help make:migration   -->  to check all commands in maigration

php artisan migrate:refresh   -->   Reset and re-run all migrations

php artisan tinker   ==> to use php in CMD
[{

    DB::table("companies")->insert(["name"=>"hello company","email"=>"email@gmail.com","location"=>"abc","created_at"=>new DateTime])

    DB::table("companies")->get()
   
    DB::table("companies")->where(["name" => "param"])->first()
   
    DB::table("companies")->pluck("col_name")->get
    EXAMPLE:-:>> DB::table("companies")->pluck("name")->get
    -> this will show all the data from column name only
   
    DB::table("companies")->select("name","email")->get()
   
    DB::table("companies")->order("id","desc")->get()
   
    DB::table("companies")->where("id","2")->update(["key"=>"value"])
   
    DB::table("companies")->where("id","2")->delete()

}]

php artisan make:model post -mc    ----->to create model as well as table of same name

php artisan make:request MyForm      ----->it will create requests folder in Http folder and also create myform.php file in at

php artisan storage:link         Create a symbolic link from "public/storage" to "storage/app/public"

Comments

Popular posts from this blog

Laravel - Remove Public from URL using htaccess

  Step 1: Rename File In first step it is very easy and you need to just rename file name. you have to rename server.php to index.php at your laravel root directory. server.php INTO index.php   Step 2: Update .htaccess first of all you have to copy .htaccess file and put it laravel root folder. You just copy .htaccess file from public folder and then update bellow code: .htaccess Options -MultiViews -Indexes RewriteEngine On # Handle Authorization Header RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} (.+)/$ RewriteRule ^ %1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f Re...