Top 10 Interview Question in Laravel 2021?

Q #1) What is Laravel?.

Laravel is a free and open-source PHP framework that is utilized to developed wide variety of web applications. Laravel is an accessible language for new programmers because the laravel community provides lots of modules resources are free available. Laravel provides a simple way to authorization logic and control access to resources with a simple ActiveRecord implementation that makes their interaction with databases.

Q #2) Define Composer.

Composer is a dependency manager for php framework. Composer runs through the command line. The main purpose of the composer is to install the dependencies or libraries for an application. Composer help to install required package component whatever you want to install in your application.

Q #3) What is Routing?

Route is a way to create request URL of your application, Route is a method of accepting a request and sending it to the relevant function in the controller.

What are the two main routing files in Laravel?

1. web.php
2. api.php

Q #4) What is a CSRF token?

Answer: CSRF is an abbreviation for Cross-Site Request Forgery that is generated by the server-side application and transmitted to the client. A CSRF token is a unique value that is generated by the server-side of the application and sent to the client

CSRF token helps to protect web applications from attacks which force a user to perform an unwanted action (commonly known as CSRF attacks).

Q #5) What is an artisan?

Artisan is the command-line tool for Laravel to help the developer build the application use while developing your application. You can enter the below command to get all the available commands:

example of commands

php artisan make:controller — Make Controller file
php artisan make:model

Q #6) How to put Laravel applications in maintenance mode?

php artisan down

And can put the application again on live using the below command:

php artisan up

Q #7) How to put Laravel applications in maintenance mode?

What are the default route files in Laravel?

web.php — For registering web routes.
api.php — For registering API routes.
console.php — For registering closure-based console commands.
channel.php — For registering all your event broadcasting channels that your application supports.

Q #8) What are seeders in Laravel?

Seeders in laravel are used to put dummy data in the database tables automatically. After running migrations to create the tables, we can run `php artisan db:seed` to run the seeder to populate the database tables.

We can create a new Seeder using the below artisan command:

php artisan make:seeder [className]

Q #9) List out common artisan commands used in Laravel.

Laravel supports following artisan commands:

PHP artisan down;
PHP artisan up;
PHP artisan make:controller;
PHP artisan make:model;
PHP artisan make:migration;
PHP artisan make:middleware;

Q #10) What is the Latest version of Laravel?

Answer: Laravel 8 is the latest version.

Thanks… 👍👍

Tagged : / / / / /

Laravel 5.5 Method paginate does not exist

When I am trying to put some value in my input search box and after pressing enter button showing above issue.
But when I am trying to filter data with my search button then it’s working fine. so i dig into it. i found one solution on it.

FilterController.php
$users = DB::table('users')
->where(function($query) use ($countryId, $stateId, $cityId) {
	if (isset($countryId) && $countryId !== null && $countryId !== '' && $stateId == 'Select State') {
		$query->where('country_id', '=', $countryId);
	}
	if (isset($countryId) && $countryId !== null && $countryId !== '' && isset($stateId) && $stateId !== 'Select State' && $stateId !== '') {
		$query->where([
							['country_id', '=', $countryId],
							['state_id', '<>', $stateId]
						]);
		
	}
})->get()->paginate(5);

Solution :

Just remove the get() and your code will work fine.

$users = DB::table('users')
->where(function($query) use ($countryId, $stateId, $cityId) {
	if (isset($countryId) && $countryId !== null && $countryId !== '' && $stateId == 'Select State') {
		$query->where('country_id', '=', $countryId);
	}
	if (isset($countryId) && $countryId !== null && $countryId !== '' && isset($stateId) && $stateId !== 'Select State' && $stateId !== '') {
		$query->where([
							['country_id', '=', $countryId],
							['state_id', '<>', $stateId]
						]);
		
	}
})->paginate(5);

References :

  1. Click here
  2. Click here
Tagged : / /

How to Embeds CodePen view in WordPress Site?

If You want to Embeds CodePen view Your wordPress Site(Blog Site) then first go to Click Here

After That You can select Any Social Site or Email for Sign Up .

After Sign Up shown below View Click Let’s Go button to Continue.

After that Show below Editor then you can edit in Codepen Editor

After that clicck to Home Button in your Codepen and Go to codepen Homepage and click Left Sidebar Pen button and to editor view & write your code and rename your page and click save button as below-

Preview of Codepen

Tagged : / / / /