Question: What are the new features of Laravel 7?
Laravel 7.0 is incorporated features such as Better routing speed, Laravel Airlock, Custom Eloquent casts, Fluent string operations, CORS support, and many more features like below.
- Custom Eloquent Casts
- Route Caching Speed Improvements
- HTTP Client
- Query Time Casts
- Blade Component Tags & Improvements
- Laravel Airlock
- CORS Support
- Fluent string operations
- Multiple Mail Drivers
- New Artisan Commands etc
Question: What is the use of dd() in Laravel?
It is a helper function which is used to dump a variable's contents to the browser.
dd($arrayData);
Question: How to make a helper file in laravel?
- Please create a app/helpers.php file in app folder.
- Add Following in in autoload variable.
"files": [ "app/helpers.php" ]
- Now update your composer.json
composer update
Question: What is PHP artisan in laravel? Name some common artisan commands?
Artisan is a type of the "command line interface" using in Laravel.
It supports following commands to execute.
- php artisan list
- php artisan –version
- php artisan down
- php artisan help
- php artisan up
- php artisan make:controller
- php artisan make:mail
- php artisan make:model
- php artisan make:migration
- php artisan make:middleware
- php artisan make:auth
- php artisan make:provider etc.
Question: What is laravel Service container?
Service Container is a powerful tool which is used to manage class dependencies and perform dependency injection.
Question: How to get last inserted id using laravel query?
$blogObj = new Blog; $blogObj->title = "Web technology experts notes"; $blogObj->save(); //Save the data echo $blogObj->id // Return the last inserted id
Question: How to use mail() in laravel?
Mail::send('emails.reminder', ['user' => $user], function ($m) use ($user) { $m->from('from@example.com', 'Send Name'); $m->to('receiver@example.com', 'Receiver Name')->subject('Your Reminder!'); });
Question: What is Auth?
Auth is in-built functionality provided by Laravel to identifying the user credentials with the database.
Question: How to make a constant? and how to use?
Add element in constants.php which should be in config folder.
return [ 'EMAIL_FROM' => 'from@example.com', ];
Get the value from config file.
echo Config::get('constants.EMAIL_FROM');//from@example.com
Question: What is with() in Laravel?
with() function is used to eager load in Laravel.
Question: How to get user’s ip address in laravel?
request()->ip()
Question: Difference between softDelete() & delete() in Laravel?
delete(): Record delete permanently.
softDelete(): records did not remove from the table only delele_at value updated with current date and time.
Question: How to enable query log in laravel?
DB::connection()->enableQueryLog(); $querieslog = DB::getQueryLog(); dd($querieslog) //Print the logs
Question: How to use skip() and take() in Laravel Query?
$posts = DB::table('blog')->skip(5)->take(10)->get();
Question: Give the list of Design Patterns in Laravel?
- The Builder pattern
- The Repository pattern
- The need for the Builder pattern
- The need for the Factory pattern
- The Factory pattern
- The Provider pattern
- The Facade pattern
- The Strategy pattern
Question: What are views?
Views contain the HTML provided by our application (UI part).
Question: What is faker in Laravel?
Faker is a type of module or packages which are used to create fake data for testing purposes.