Controllers in Laravel 5.3

As we have seen in previous example of passing arguments to view, the route file actually looks ugly and hard to read. As we know Laravel use MVC (Model View Controller) , it is best to use a controller for that example. In short it is best to include any logic in controller. A controller may have one or more than one action. Lets understand controller with an example. To create an boilerplate code for an controller we have to pass following command in root of the project directory....

January 23, 2017 · Kunal Gautam

Working With If Else in Laravel 5.3 using Blade

As we have seen in earlier tutorial about Loops, let see how to use if statements in Blade Template engine. If Else Condition In above code, we have checked if $var is empty, if it is empty output It is empty, else output It is not empty. if condition can also be used for comparison. For example: Unless statement Unless is generally “if not” condition. For example: In this example if $var is empty, it will not process this loop and exit....

January 22, 2017 · Kunal Gautam

Working With Loops in Laravel 5.3 using Blade

As we have seen how to use PHP codes in our blade template file, lets move to loops in Blade Template. For Loop For Each Loop While Loop

January 22, 2017 · Kunal Gautam

Blade Template - Beginners level tips for Laravel 5.3

As we have seen in previous tutorial we have echoed date. In this tutorial we will learn some more advance stuffs in blade template engine Now the above example can be further simplified using only following code : {{ echo date('l jS \of F Y h:i:s A'); }} The curly brackets used are template shortcut for echo function. But double curly brackets are used to prevent the code from XSS attacks by stripping HTML entities....

January 22, 2017 · Kunal Gautam

Getting Started - Using PHP functions in blade template files

There are many useful PHP functions which an developer might use from time to time in their application. To use PHP in a blade there are two methods: Traditional method Blade Template method Traditional Method You can simply insert your PHP code within php tags and it will work. For example: The above will echo something like: Sunday 22nd of January 2017 09:25:00 PM But it is good and easy to use Blade Template method....

January 22, 2017 · Kunal Gautam

Getting Started - Where to store my CSS and JS in Laravel 5.3?

So now a nice HTML page can be designed, it is common practice to use CSS and JS externally in page. The question arises, where to store our CSS and JS files to be used with Laravel? All CSS & JS should be placed under public directory under root of your project directory. It can be called in blade file as {{ URL::asset('css/cssfile.css') }} For example a css.css file from css folder under public directory ( public/css/css....

January 21, 2017 · Kunal Gautam

Getting Started - Views in Laravel 5.3

In the last tutorial we have seen a way to get text output. You can also return whole HTML code in the output, but that will make the routes file little bit ugly and hard to read. Instead of using HTML code there, view method is called. So whenever view method is called upon, it search for the view file inside the resources/views folder. These files are called blade template file....

January 21, 2017 · Kunal Gautam

Getting Started - Hello World! in Laravel 5.3

To get started with basic page running in Laravel, we will open file called web.php which is inside routes folder (i.e. inside ’laravel_project_folder/routes/web.php’). Delete existing content in the file and add following code to get started with. By using the above code, whenever a get request for base directory is passed to the server, it will return “Hello World!” as an output. To see output we need to get back to terminal and pass the following command in the directory where the Laravel project is present....

January 20, 2017 · Kunal Gautam

Laravel 5.3 Understanding File and Directory Structure

Laravel follows the model–view–controller (MVC) architectural pattern. Hence the directory structure can be confusing for a person who is not much seen into MVCs. But It is very easy to understand. I’ll cover the basic directories which are mostly used. If anything you don’t understand, I’d suggest to progress further, it will get clear by developing on the platform. So Let Get started with Directory Structure. There are many files in your root of Application director....

January 17, 2017 · Kunal Gautam

Laravel 5.3 Installation

Laravel need following perquisites to get working: PHP >= 5.6.4 OpenSSL PHP Extension PDO PHP Extension Mbstring PHP Extension Tokenizer PHP Extension XML PHP Extension I will be using PHP 7.0 along with mysql for my database requirement. There may be different way to install Laravel project, but as per official documentation, it utilize Composer to manage its dependencies. To install Composer one can follow instructions at their official website which can be found here....

January 17, 2017 · Kunal Gautam