Laravel Tutorials
- What is laravel
- Laravel Installation
- Directory Structure
- htaccess
- Remove public from url
- Artisan Command
- Laravel Configuration
- Routing Configuration
- Namespaces
- Request
- Response
- Controller
- Model
- User Authentication
- Multi User Authentication
- Database Seeding
- Database
- Database Query
- ORM
- One-to-One Relationship
- One-to-Many Relationship
- Many to Many Eloquent Relationship
- Has One Through
- Has Many Through
- Querying Relations
- Middleware
- Laravel Views
- Blade Views
- Print data on view page
- Get Site URL
- Get URL Segment
- Get images from Storage folder
- Clear cache
- Form Class not found
- Flash Message in laravel
- Redirections
- path
- CRUD Projerct
- CRUD in Laravel
- CRUD progran
- Laravel Validation
- Jquery Validation
- Cookie
- Session
- Email Send in laravel
- File uploading
- CSRF Protection
- Helper in Laravel
- Helper Functions
- Guzzle Http Client
- Paypal Payment Gatway Integration
- Cron Job in laravel
- Flash message
- path
- Errors Handling
- Date Format
- Date Format Validation
- Display Image on View Page
- Update User Status using toggle button
- Delete Multiple Records using Checkbox in Laravel?
- Confirmation Before Delete Record
- Delete image from storage
- Remove/Trim Empty & Whitespace From Input Requests
- Block IP Addresses from Accessing Website
- How to Disable New User Registration in Laravel
- Redirect HTTP To HTTPS Using Laravel Middleware
- CKEditor
- slug generate unique
- Prevent Browser's Back Button After Logout
- Datatable dunamically
- encrypt & Decript
- Download File
- Rest API
- Shopping Cart
- Shopping Cart Example
- Dynamic Category-Subcategory Menu
- Ajax Search
- Interview Question
- laravel Tutorilal link
- laravel Tutorilal
Important Links
What is Artisan Command in laravel?
Artisan is the name of the command-line interface. It provides a number of helpful commands for laravel application development.
File name : index.php
php artisan list
php artisan list
To view a list of all available Artisan commands, you may use the list command:
c:\\xampp\htdocs\itechxpert> php artisan list
list of artisan command:-
php artisan list
Laravel Framework 6.0.3
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
clear-compiled :- Remove the compiled class file
down :- Put the application into maintenance mode
env :- Display the current framework environment
help :- Displays help for a command
inspire :- Display an inspiring quote
list :- Lists commands
migrate :- Run the database migrations
optimize :- Cache the framework bootstrap files
preset :- Swap the front-end scaffolding for the application
serve :- Serve the application on the PHP development server
tinker :- Interact with your application
up :- Bring the application out of maintenance mode
auth
auth:clear-resets :- Flush expired password reset tokens
cache
:-
cache:clear :- Flush the application cache
cache:forget :- Remove an item from the cache
cache:table :- Create a migration for the cache database table
config
config:cache :- Create a cache file for faster configuration loading
config:clear :- Remove the configuration cache file
db
db:seed :- Seed the database with records
db:wipe :- Drop all tables, views, and types
event
event:cache :- Discover and cache the application's events and listeners
event:clear :- Clear all cached events and listeners
event:generate :- Generate the missing events and listeners based on registration
event:list :- List the application's events and listeners
flare
flare:test :- Send a test notification to Flare
key
key:generate :- Set the application key
make
make:channel :- Create a new channel class
make:command :- Create a new Artisan command
make:controller :- Create a new controller class
make:event :- Create a new event class
make:exception :- Create a new custom exception class
make:factory :- Create a new model factory
make:job :- Create a new job class
make:listener :- Create a new event listener class
make:mail :- Create a new email class
make:middleware :- Create a new middleware class
make:migration :- Create a new migration file
make:model :- Create a new Eloquent model class
make:notification :- Create a new notification class
make:observer :- Create a new observer class
make:policy :- Create a new policy class
make:provider :- Create a new service provider class
make:request :- Create a new form request class
make:resource :- Create a new resource
make:rule :- Create a new validation rule
make:seeder :- Create a new seeder class
make:test :- Create a new test class
migrate
migrate:fresh :- Drop all tables and re-run all migrations
migrate:install :- Create the migration repository
migrate:refresh :- Reset and re-run all migrations
migrate:reset :- Rollback all database migrations
migrate:rollback :- Rollback the last database migration
migrate:status :- Show the status of each migration
notifications
notifications:table :- Create a migration for the notifications table
optimize
optimize:clear :- Remove the cached bootstrap files
package
package:discover :- Rebuild the cached package manifest
queue
queue:failed :- List all of the failed queue jobs
queue:failed-table :- Create a migration for the failed queue jobs database table
queue:flush :- Flush all of the failed queue jobs
queue:forget :- Delete a failed queue job
queue:listen :- Listen to a given queue
queue:restart :- Restart queue worker daemons after their current job
queue:retry :- Retry a failed queue job
queue:table :- Create a migration for the queue jobs database table
queue:work :- Start processing jobs on the queue as a daemon
route
route:cache :- Create a route cache file for faster route registration
route:clear :- Remove the route cache file
route:list :- List all registered routes
schedule
schedule:run :- Run the scheduled commands
session
session:table :- Create a migration for the session database table
storage
storage:link :- Create a symbolic link from "public/storage" to "storage/app/public"
vendor
vendor:publish :- Publish any publishable assets from vendor packages
view
view:cache :- Compile all of the application's Blade templates
view:clear :- Clear all compiled view files
Forms
composer require illuminate/html
it add the serviceprovider and html form in config/app.php file
Collective\Html\HtmlServiceProvider::class,
'Form' => Illuminate\Html\FormFacade::class,
'Html' => Illuminate\Html\HtmlFacade::class,
Note :- Problem 1 (it works laravel version 5)
- illuminate/html[dev-master, v5.0.0] require illuminate/http ~5.0 -> found illuminate/http[v5.0.0, ..., 5.8.x-dev] but these were not loaded, likely because it conflicts with another require.
collective not found
File name : index.php
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Collective\Html\HtmlServiceProvider' not found
then, go on composer
c:/xampp/htdocs/mylara> composer require laravelcollective/html
composer dump-autoload
Then run:
composer update
Viewing The Help Screen For A Command
Every command also includes a "help" screen which displays and describes the command's available arguments and options. To view a help screen, simply precede the name of the command with help:
php artisan help migrate
Configuration Environment
You may specify the configuration environment that should be used while running a command using the --env switch:
php artisan migrate --env=local
Displaying Your Current Laravel Version
iew the current version of your Laravel installation using the --version option:
php artisan --version
Generating Commands
To create a new command, use the make:command Artisan command. This command will create a new command class in the app/Console/Commands directory. Don't worry if this directory does not exist in your application, since it will be created the first time you run the make:command Artisan command. The generated command will include the default set of properties and methods that are present on all commands:
php artisan make:command SendEmails
Closure Commands
Closure based commands provide an alternative to defining console commands as classes. In the same way that route Closures are an alternative to controllers, think of command Closures as an alternative to command classes. Within the commands method of your app/Console/Kernel.php file, Laravel loads the routes/console.php file:
how to install laravel?
c:\xampp\htdocs>composer create-project laravel/laravel itechxpert --prefer-dist
OR
c:\xampp\htdocs>composer create-project laravel/laravel itechxpert
Start the Laravel service by executing the following command.
c:/xampp/htdocs/itechxpert>php artisan serve
To view help about any command and view the available options and arguments
php artisan help serve
Writing Commands
a user can also create a custom command which can be used in the web application. Please note that commands are stored in app/console/commands directory.
php artisan make:console
Migrations
To create a migration, use the make:migration Artisan command:
php artisan make:migration create_users_table
How to create controller using command
php artisan make:controller conytroller_Name
php artisan make:controller ControllerName --plain
php artisan make:controller admin/conytroller_Name
Here admin is directory name. in which you create a controller.
invokable controller by using the --invokable option
php artisan make:controller ShowProfile --invokable
Routing Auth:-
Laravel provides a quick way to scaffold all of the routes and views you need for authentication using one simple command:
php artisan make:auth
php artisan migrate
Clear Application Cache
Run the following command to clear the application cache of the Laravel application.
php artisan cache:clear
Clear Route Cache
To clear route cache of your Laravel application execute the following command from the shell.
php artisan route:clear
Clear Configuration Cache
You can use config:clear to clear the config cache of the Laravel application.
php artisan config:clear
Clear Compiled Views Cache
clear compiled view files of your Laravel application
php artisan view:clear
composer dump
composer dump-autoload
Clear Cache in Laravel (Browser)
Most of the shared hosting providers don’t provide SSH access to the systems. In that case, you can clear the Laravel cache by calling the URL in the browser. You can simply place the below code in your routes/web.php file of the Laravel application.
Route::get('/clear-cache', function() {
Artisan::call('cache:clear');
return "Cache is cleared";
});
-mc
it create model and migration class both
php artisan make:model FileUploadModel -mc
How to set assets folder in public directory?
Add ASSET_URL=public in your .env file and run php artisan config:cache
ASSET_URL=public
php artisan config:cache
config/app.php
Set assets url in app.php
'asset_url' => env('ASSET_URL', 'https://www.example.com'),
access your assets
asset('public/assets/css/sample.css')