Wednesday, 1 April 2020

Laravel interview questions for 1 year experience

Laravel interview questions for 1 year experience

Question: How to make a helper file in laravel?
  1. Please create a app/helpers.php file in app folder.
  2. Add Following in in autoload variable.
    "files": [
  3. Now update your composer.json
    composer update

Question: How to use mail() in laravel?
Mail::send('emails.reminder', ['user' => $user], function ($m) use ($user) {
    $m->from('', 'Send Name');
    $m->to('', 'Receiver Name')->subject('Your Reminder!');

Question: What is a REPL?
REPL is a type of interactive shell that takes in single user inputs, process them, and returns the result to the client. The full form of REPL is Read—Eval—Print—Loop

Question: How to use update query in Laravel?
Use Update function. for example
Blog::where(['id' => 10023])->update([
   'title' => 'Interview Questions',
   'content’ => 'Web Technology exerts notes'

Question: How to use multiple OR condition in Laravel Query?
Blog::where(['id' => 10023])->orWhere(['username’ => 'username12'])->update(['title' => 'Interview Questions',]);

Question: What are different type of where Clauses in Laravel?
  1. where()
  2. orWhere()
  3. whereBetween()
  4. orWhereBetween()
  5. whereNotBetween()
  6. orWhereNotBetween()
  7. wherein()
  8. whereNotIn()
  9. orWhereIn()
  10. orWhereNotIn()
  11. whereNull()
  12. whereNotNull()
  13. orWhereNull()
  14. orWhereNotNull()
  15. whereDate()
  16. whereMonth()
  17. whereDay()
  18. whereYear()
  19. whereTime()
  20. whereColumn()
  21. orWhereColumn()
  22. whereExists()

Question: What is updateOrInsert method? Give example?
updateOrInsert() method is used to update an existing record in the database if matching the condition or create if no matching record exists.
   'title' => 'Interview Questions',   

Question: How to check table is exists or not in our database using Laravel?
if(Schema::hasTable('users')) {
    echo "Table Exists";
} else {
    echo "Table does not exists"

Question: How to check column is exists or not in a table using Laravel?
if(Schema::hasColumn('users', 'title')) ; //check whether admin table has username column
   echo "Column Exists in table";
    echo "Column does not Exists in table";

Question: What are the difference between insert() and insertGetId() in laravel?
Inserts(): This method is used for insert records into the database table.
insertGetId(): This method is used for insert records into the database table and return the autoincrement-id.

Question: What is lumen?
Lumen is a PHP framework which is a faster, smaller and leaner version of a full web application framework.

Question: What is the full form of ORM in Laravel?
Object Relational Mapping.

Question: How to get current route name and method name?
request()->route()->getName(); //Return route name
request()->route()->getActionMethod();//Return method name

Question: How to check Ajax request in Laravel?
You can use the following syntax to check ajax request in laravel.
if ($request->ajax()) {
     echo "This is ajax requrest";

Question: What do you mean by bundles? In Laravel, bundles are referred to as packages.
These packages are used to increase the functionality of Laravel.
A package can have views, configuration, migrations, routes, and tasks.

Question: Name databases supported by Laravel.

  1. PostgreSQL
  2. SQL Server
  3. SQLite
  4. MySQL