By OnlineInterviewQuestions com Php laravel Interview Questions What is Laravel?



Download 39.11 Kb.
View original pdf
Page5/9
Date17.09.2022
Size39.11 Kb.
#156480
1   2   3   4   5   6   7   8   9
laravel-interview-questions

What are Laravel eloquent?
Laravel's Eloquent ORM is simple Active Record implementation for working with your database. Laravel provide many different ways to interact with your database, Eloquent is most notable of them. Each database table has a corresponding Model which is used to interact with that table. Models allow you to query for data in your tables, as well as insert new records into the table.
Below is sample usage for querying and inserting new records in Database with Eloquent Querying or finding records from products table where tag is 'new'
$products= Product::where('tag','new');
// Inserting new record product new Product;
$product->title="Iphone 7";
$product->price="$700";
$product->tag='iphone';
$product->save();
Q17.
How to enable query login Laravel ?

Use the enableQueryLog method to enable query login Laravel
DB::connection()->enableQueryLog(); You can get array of the executed queries by using getQueryLog method:
$queries = DB::getQueryLog();
Q18.
What is reverse routing in Laravel?
Laravel reverse routing is generating URLs based on route declarations. Reverse routing makes your application so much more flexible. It defines a relationship between links and Laravel routes. When a link is created by using names of existing routes, appropriate Uris are created automatically by Laravel. Here is an example of reverse routing route declaration
Route::get('login', 'users@login');
Using reverse routing we can create a link to it and pass in any parameters that we have defined. Optional parameters, if not supplied, are removed from the generated link HTML::link_to_action('users@login') It will automatically generate an Url like http://xyz.com/login in view.
Q19.
How to turnoff CRSF protection for specific route in Laravel?
To turnoff CRSF protection in Laravel add following codes in “app/Http/Middleware/VerifyCsrfToken.php”
//add an array of Routes to skip CSRF check private $exceptUrls = ['controller/route1', 'controller/route2'];
//modify this function public function handle($request, Closure next) add this condition foreach($this->exceptUrls as route) if ($request->is($route)) return $next($request);
}
}
return parent::handle($request, next

Download 39.11 Kb.

Share with your friends:
1   2   3   4   5   6   7   8   9




The database is protected by copyright ©essaydocs.org 2022
send message

    Main page