InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 301. |
How to use aggregate functions in Laravel? |
|
Answer» Laravel provides a variety of aggregate functions such as MAX, min, count,avg, and sum. We can call any of these functions after CONSTRUCTING our QUERY. $users = DB::table(‘admin’)->count(); |
|
| 302. |
How to create real time sitemap.xml file in Laravel? |
|
Answer» We can create all web PAGES of our sites to tell Google and other search engines like Bing, Yahoo etc about the organization of our site content. These search engine web crawlers read this file to more intelligently crawl our sites. Here are the steps that helps you to create real time sitemap.xml file and these steps ALSO helps to create dynamic XML files.
|
|
| 303. |
Which template engine laravel use? |
|
Answer» LARAVEL uses "Blade TEMPLATE Engine". It is a STRAIGHTFORWARD and POWERFUL templating engine that is provided with Laravel. |
|
| 304. |
How to use maintenance mode in Laravel 5? |
|
Answer» We have to use the FOLLOWING ARTISAN COMMANDS to enable/disable maintenance mode in LARAVEL 5. Enable maintenance modephp artisan down Disable maintenance modephp artisan up |
|
| 305. |
What is composer lock in laravel? |
|
Answer» After RUNNING the composer INSTALL in the PROJECT directory, the composer will generate the composer.lock file.It will KEEP a record of all the DEPENDENCIES and sub-dependencies which is being installed by the composer.json. |
|
| 306. |
What is Eloquent ORM in Laravel? |
|
Answer» Laravel involves Eloquent ORM (Object Relational Mapper), which makes it fun to interact with the database. While using Eloquent, every database table CONTAINS their corresponding “MODEL” that is being used for INTERACTION with that table. The eloquent model also ALLOWS the people to insert, update, and delete the RECORDS from the table. We can create Eloquent models using the make:model command. It has many types of relationships.
|
|
| 307. |
How to use multiple databases in Laravel? |
|
Answer» To use multiple databases in Laravel, FOLLOW these steps carefully.
DB_CONNECTION=mysql DB_CONNECTION_SECOND=mysql 'mysql' => [ 'mysql2' => [ $users = DB::connection('your_db_name2')->select(); |
|
| 308. |
How to mock a static facade method in Laravel? |
|
Answer» In Laravel, FACADES are used to provide a static interface to classes available inside the application's SERVICE container. Now, unlike conventional static method CALLS, facades can be mocked in Laravel. It can be done using the shouldRecieve method, which shall RETURN an instance of a FACADE mock. Example$value = Cache::get('key'); Cache::shouldReceive('get')->once()->with('key')->andReturn('value'); |
|
| 309. |
How to use soft delete in laravel? |
|
Answer» Soft delete is a laravel feature that helps When models are soft DELETED, they are not actually removed from our database. Instead, a deleted_at TIMESTAMP is SET on the record. To enable soft deletes for a model, we have to specify the soft delete property on the model like this. In model we have to use namespace and we can use this After that when we will use delete() query then records will not REMOVE from our database. then a deleted_at timestamp is set on the record. |
|
| 310. |
How to upload files in laravel? |
|
Answer» We have to call FACADES in our controller file with this : if($REQUEST->hasFile(file_name')) { |
|
| 311. |
How to get client IP address in Laravel 5? |
|
Answer» You can USE request()->IP(); You can ALSO use : Request::ip() but in this case, we have to CALL namespace like this: Use Illuminate\Http\Request; |
|
| 313. |
How to use joins in laravel? |
|
Answer» Laravel SUPPORTS VARIOUS joins that's are GIVEN below:-
|
|
| 314. |
What is with() in Laravel? |
|
Answer» with() function is used to eager load in Laravel. Unless of USING 2 or more separate QUERIES to fetch data from the database, we can use it with() method after the first command. It provides a better user experience as we do not have to wait for a LONGER period of time in fetching data from the database. 31. How to remove /PUBLIC from URL in laravel?You can do this in various ways. Steps are given below:-
|
|
| 315. |
What is Auth? How is it used? |
|
Answer» Laravel AUTH is the process of identifying the user credentials with the database. Laravel managed it's with the help of sessions which take INPUT parameters LIKE USERNAME and password, for user identification. If the settings match then the user is said to be authenticated. Auth is in-built functionality provided by Laravel; we have to configure. We can add this functionality with php ARTISAN make: auth Auth is used to identifying the user credentials with the database. |
|
| 316. |
How to use cookies in laravel? |
|
Answer» 1. How to set COOKIE To set cookie value, we have to use Cookie::put('key', 'value'); 2. How to get CookieTo get cookie Value we have to use Cookie::get('key'); 3. How to DELETE or remove CookieTo remove cookie Value we have to use Cookie::forget('key') 4. How to check CookieTo Check cookie is exists or not, we have to use Cache::has('key') |
|
| 317. |
How to use mail() in laravel? |
|
Answer» LARAVEL provides a powerful and clean API over the SwiftMailer library with drivers for Mailgun, SMTP, AMAZON SES, SparkPost, and send an email. With this API, we can send email on a local SERVER as well as the live server. Here is an example through the mail()Laravel allows us to store email messages in our views files. For example, to manage our emails, we can create an email directory WITHIN our resources/views directory. Examplepublic function sendEmail(Request $request, $id) |
|
| 318. |
What are the difference between softDelete() & delete() in Laravel? |
|
Answer» 1. delete() In case when we used to delete in Laravel then it REMOVED records from the database table. Example:$delete = Post::where(‘id’, ‘=’, 1)->delete(); 2. softDeletes()To delete records permanently is not a good THING that’s why laravel used features are called SoftDelete. In this case, records did not REMOVE from the table only delele_at VALUE updated with current date and time. use SoftDeletes; $softDelete = Post::where(‘id’, ‘=’, 1)->delete(); OR $softDelete = Post::where(‘id’, ‘=’, 1)->softDeletes(); |
|
| 319. |
How to get last inserted id using laravel query? |
|
Answer» In case you are using SAVE() $BLOG = new Blog; // Now you can USE (after save() FUNCTION we can use like this) $blog->ID // It will display last inserted id In case you are using insertGetId()$insertGetId = DB::table(‘blogs’)->insertGetId([‘title’ => ‘Best Interview Questions’]); |
|
| 320. |
How to use session in laravel? |
|
Answer» 1. RETRIEVING DATA from session 2. Retrieving All session data 3. Remove data from session 4. STORING Data in session |
|
| 321. |
What is Service container? |
|
Answer» A laravel service CONTAINER is ONE of the most powerful TOOLS that have been used to manage dependencies over the class and perform dependency injections. Advantages of Service Container |
|
| 322. |
What are the steps to install Laravel with composer? |
|
Answer» Laravel installation steps:-
If you did not MENTION any particular version, then it will install with the latest version. |
|
| 323. |
How to make a helper file in laravel? |
|
Answer» We can CREATE a helper FILE using Composer. Steps are given below:-
|
|
| 324. |
What is the use of dd() in Laravel? |
|
Answer» It is a HELPER function which is USED to dump a variable's contents to the browser and STOP the further script execution. It stands for Dump and Die. ExampleDD($array); |
|
| 325. |
What is Facade and how it can be used in Laravel? |
|
Answer» The facade gives the “static” interface to all the classes available in the service container of the application. Laravel comes along with many interfaces that provide the ACCESS to almost all the features of Laravel. All the facades are defined in the NAMESPACE Illuminate\Support\Facades for easy ACCESSIBILITY and usability. Exampleuse Illuminate\Support\Facades\Cache; ROUTE::get('/cache', function () { return Cache::get('PutkeyNameHere'); }); |
|
| 326. |
How to use Stored Procedure in Laravel? |
|
Answer» How to create a Stored PROCEDURE To create a Stored Procedure you can execute given code in your MySQL query builder directly or use phpmyadmin for this. DROP PROCEDURE IF EXISTS `get_subcategory_by_catid`; After this, you can use this CREATED procedure in your code in Laravel. How to use stored procedure in Laravel$getSubCategories = DB::select( |
|
| 327. |
How do you make and use Middleware in Laravel? |
|
Answer» It acts as a middleman between a request and a response. Middleware is a type of filtering mechanism used in Laravel application.
|
|
| 328. |
How to turn off CSRF protection for a particular route in Laravel? |
|
Answer» We can add that PARTICULAR URL or ROUTE in $EXCEPT variable. It is present in the app\Http\Middleware\VerifyCsrfToken.php file. ExampleCLASS VerifyCsrfToken extends BaseVerifier { |
|
| 329. |
How to get data between two dates in Laravel? |
|
Answer» In Laravel, we can USE whereBetween() function to get DATA between two dates. ExampleUsers::whereBetween('created_at', [$firstDate, $secondDate])->get(); |
|
| 330. |
What are the steps to create packages in Laravel? |
|
Answer» Follow these STEPS to SUCCESSFULLY create a package in Laravel:
|
|
| 331. |
What is service providers? |
|
Answer» Service providers are the fundamentals of bootstrapping laravel applications. All the core services of Laravel are bootstrapped through service providers. This powerful tools are used by developers to manage CLASS dependencies and perform dependency injection. To create a service provider, we have to use the below-mentioned ARTISAN COMMAND. You can use php artisan make: provider ClientsServiceProvider artisan command to generate a service provider : It has below LISTED FUNCTIONS in its file.
|
|
| 332. |
What is reverse Routing in Laravel? |
|
Answer» Reverse routing in the laravel means the process that is used to GENERATE the URLs which are BASED on the names or symbols. URLs are being generated based on their route declarations. With the use of reverse routing, the application becomes more flexible and provides a better interface to the developer for writing cleaner codes in the View. ExampleRoute:: get(‘list’, ‘[EMAIL PROTECTED]’); In between head, tag put <meta name="csrf-token" content="{{ csrf_token() }}"> and in Ajax, we have to ADD |
|
| 333. |
What is Database Migration and how to use this in Laravel? |
|
Answer» Database migration is like the VERSION control of the database, which allows the team to modify and share the database SCHEMA of the application. Database migrations are paired with the schema builder of Laravel which is used to build the database schema of the application. It is a type of version control for our database. It is allowing US to modify and share the application's database schema easily. A migration file contains two methods up() and down(). up() is used to add new tables, columns, or indexes database and the down() is used to reverse the operations performed by the up method. ExampleYou can generate a migration & its file with the help of make:migration. SYNTAX : PHP artisan make:migration blog A current_date_blog.php file will be create in database/migrations |
|
| 334. |
What is the difference between {{ $username }} and {!! $username !!} in Laravel? |
|
Answer» {{ $USERNAME }} is SIMPLY used to display text contents but {!! $username !!} is used to display CONTENT with HTML tags if EXISTS. |
|
| 335. |
What is Middleware in Laravel? |
|
Answer» MIDDLEWARE in laravel works as a platform among the REQUEST and the response. It provides the mechanism for INVESTIGATING the HTTP requests which are entering into your application. For instance, middleware in laravel ensures that the user of your particular application is authenticated. If they found that the user is not authenticated, it will redirect the user to the main login PAGE of the application. Example: If a user is not authenticated and it is trying to access the dashboard then, the middleware will redirect that user to the login page. |
|
| 336. |
How to enable query log in laravel? |
|
Answer» Our FIRST step should be DB::connection()->enableQueryLog(); After our query, it should be PLACED $querieslog = DB::getQueryLog(); After that, it should be placed dd($querieslog) ExampleDB::connection()->enableQueryLog(); $RESULT = User:where(['status' => 1])->GET(); $log = DB::getQueryLog(); dd($log); |
|
| 337. |
How to make a constant and use globally? |
|
Answer» You can create a constants.php page in config folder if does not EXIST. Now you can put constant VARIABLE with value here and can USE with Config::get('constants.VaribleName'); ExampleRETURN [ |
|
| 338. |
Which is better CodeIgniter or Laravel? |
||||||||||||||
|
Answer» Here are some of the reasons why Laravel is considered to be better than CodeIgniter:
|
|||||||||||||||
| 339. |
How to extend login expire time in Auth? |
|
Answer» You can EXTEND the LOGIN expire time with config\session.php this file location. Just update lifetime the value of the variable. By default it is 'lifetime' => 120. According to your REQUIREMENT update this variable. Example'lifetime' => 180 |
|
| 340. |
Why laravel is the best PHP framework in 2021? |
| Answer» | |
| 341. |
What's New in Laravel 8? |
|
Answer» Laravel 8.0 is incorporated with a NUMBER of latest features such as Laravel JETSTREAM, model directory, MIGRATION squashing, rate limiting improvements, model factory classes, TIME testing helpers, dynamic blade components and, much more. The Laravel 8.0 released on 8th September 2020 with the latest and unique features. NEW Features in Laravel 8
|
|
| 342. |
Does Laravel support caching? |
|
Answer» YES, LARAVEL supports CACHING of popular BACKENDS such as Memcached and Redis. |
|
| 343. |
What is Modules in OpenCart? |
|
Answer» It is a TYPE of add-ons like PLUGINS or extensions in other CMS. These modules gives us the ability to enhance its FUNCTIONALITY without edit its application FILES. |
|
| 344. |
What do you meand by Ocmod in opencart? |
|
Answer» It is a system that allows USERS to be able to MODIFY their store by uploading a compressed file which contains XML file and SQL file and PHP FILES. |
|
| 345. |
What are the payment methods are available with in OpenCart installation? |
| Answer» | |
| 346. |
Explain the difference between Opencart 1.xx and newer than 2.xx? |
Answer»
|
|
| 347. |
List some reasons, why we Choose OpenCart? |
Answer»
|
|
| 348. |
What is the difference between opencart and magento? Explain |
Answer»
Conclusion : Magento is best choice for large business with HUGE budget and OpenCart is best for small business with low budget. It depends on users to choose a platform according to their need & requirements. |
|
| 349. |
OpenCart is CMS or Framework? Explain |
|
Answer» It is ecommerce CMS solution that OFFERS VARIOUS features for online RETAILERS. It is an open SOURCE and free to use which makes it a cost-effective solution for all small and MEDIUM ecommerce sites. |
|
| 350. |
Is OpenCart free?Explain |
|
Answer» It is a free, simple, powerful and open SOURCE ECOMMERCE PLATFORM that can HELP us to built eCommerce website for SELLING our products & services. |
|