Laravel – Forms

Laravel provides various in built tags to handle HTML forms easily and securely. All the major elements of HTML are generated using Laravel. To support this, we need to add HTML package to Laravel using composer. Example 1 Step 1 − Execute the following command to proceed with the same. This …

Read More »

Laravel – Errors and Logging

Errors and exception handling is already configured for you when you start a new Laravel project. Normally, in a local environment we need to see errors for debugging purposes. We need to hide these errors from users in production environment. This can be achieved with the variable APP_DEBUG set in the environment …

Read More »

Laravel – Working With Database

Laravel has made processing with database very easy. Laravel currently supports following 4 databases − MySQLPostgresSQLiteSQL Server The query to the database can be fired using raw SQL, the fluent query builder, and the Eloquent ORM. To understand the all CRUD (Create, Read, Update, Delete) operations with Laravel, we will …

Read More »

Laravel – Redirections

Named route is used to give specific name to a route. The name can be assigned using the “as” array key. Route::get('user/profile', ['as' => 'profile', function () { // }]); Redirecting to Named Routes Example Observe the following example to understand more about Redirecting to named routes − Step 1 − Create a …

Read More »

Laravel – Blade Templates

Laravel 5.1 introduces the concept of using Blade, a templating engine to design a unique layout. The layout thus designed can be used by other views, and includes a consistent design and structure. When compared to other templating engines, Blade is unique in the following ways − It does not restrict …

Read More »

Laravel – Views

In MVC framework, the letter “V” stands for Views. It separates the application logic and the presentation logic. Views are stored in resources/views directory. Generally, the view contains the HTML which will be served by the application. Example Observe the following example to understand more about Views − Step 1 − Copy the following code and …

Read More »

Laravel – Response

Response can be sent either from route or from controller. This string will be automatically converted to appropriate HTTP response. Example Step 1 − Add the following code to app/Http/routes.php file. Route::get('/basic_response', function () { return 'Hello World'; }); Step 2 − Visit the following URL to test the basic response. http://localhost:8000/basic_response Step 3 − The output will …

Read More »

Laravel – Cookie

Cookies play an important role while dealing a user’s session on a web application. Cookie can be created by global cookie helper of Laravel. It is an instance of Symfony\Component\HttpFoundation\Cookie. The cookie can be attached to the response using the withCookie() method. Create a response instance of Illuminate\Http\Response class to call the withCookie() …

Read More »

Laravel Request

Retrieving the Request URI The “path” method is used to retrieve the requested URI. The is method is used to retrieve the requested URI which matches the particular pattern specified in the argument of the method. To get the full URL, we can use the url method. Example Step 1 − Execute the below command to create …

Read More »

Laravel Controllers

In the MVC(Model View Controller) framework, the letter ‘C’ stands for Controller. It acts as moving the traffic back and forth between model and views. Creating a Controller Type the following command to create controller using the Artisan CLI (Command Line Interface). php artisan make:controller <controller-name> --plain This will create …

Read More »