Laravel Working With Database

The MVC framework has made it easy to integrate database. It currently supports only 4 major databases which are MySQL, Postgres, SQLite, and SQL Server.You can fire a query to any of these databases by the use of raw SQL, Eloquent ORM, and the fluent query builder. Here, we will be focusing mainly on theRead More

Laravel Redirections

Named Routes Redirection You can provide the desired name to a route. For this purpose, you have the liberty to use “as”, which is an array key. Also Read: Laravel Views Route::get(‘user/profile’, [‘as’ => ‘profile’, function() { // }]); Explanation: Here, we have named the user/profile route as profile. You can use any other nameRead More

Laravel Views

Views By now, you must have understood the importance of Views. In fact, the MVC framework itself emphasizes the importance of V as Views. In simple words, a view acts as a bridge between application logic and the presentation logic. You can locate this bridge i.e., views within the resources/views directory. Well generally, views areRead More

Laravel Cookie

Cookie Creation You can create a cookie by the use of Laravel’s global cookie helper. The global cookie helper is nothing but an instance of Symfony\Component\HttpFoundation\Cookie. A programmer can integrate a cookie with the response by the help of withCookie() method. Well, to call the withCookie() method, you need to create an instance for theRead More

Laravel Response

Basic Response Each and every request is linked with a response. The MVC framework offers you various ways through which you can return a response to a request. You can send the response through two ways: 1. through route 2. through controller. Take a look at the below given sample code to understand how toRead More

Laravel Middleware

Middleware Middleware acts as a filter between the request and the response. For an instance, A middleware of Laravel is used to verify the authenticated users. An authenticated user will get redirected to the dashboard otherwise, the user will remain on the same page. Command to create middleware: laravel> php artisan make:middleware <middleware-name>  You needRead More

Laravel Controllers

 Controllers In any of the MVC frameworks, ‘C’ is usually used to denote Controller. It helps in directing the traffic from views to models and vice versa. Controller Creation We will be creating the controller by using the Artisan CLI (Command Line Interface). To start with the process, first type in the mentioned command eitherRead More

Laravel Request

Retrieval of the Request URI/Path If you want to retrieve a requested URI then you have to use the ‘path’ method. There is another method called ‘is’. This method works when you want to match the requested URI to the specific argument passed in the method. And, if you want to retrieve the complete URLRead More

Laravel Routing

The basic routes are defined in the app directory under the name ‘routes.php’. Basic Routing The basic routing is responsible for routing all your requests to the respective controller. Below are the several general syntaxes for the basic routing. GET Route Route: :get(‘/’, function() { return ‘Hello World’; }); POST Route Route: :post(‘foo/bar’, function() {Read More

Laravel Configuration

Basic Configuration After the installation of Laravel, you will be required to set an application key to a random string. This step is not required if you have installed Laravel with the help of the Composer. In such a case, the application key has already been set with the help of the command ‘key:generate’. ThisRead More