By OnlineInterviewQuestions com Php laravel Interview Questions What is Laravel?

Download 39.11 Kb.
View original pdf
Size39.11 Kb.
1   2   3   4   5   6   7   8   9

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";
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();
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 in view.
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 © 2022
send message

    Main page