Setup Menus in Admin Panel

  • No products in the cart.

  • LOGIN

MVC Concepts

Laravel applications follow the traditional Model-View-Controller(MVC) design pattern. This pattern helps you to tier your code for easier maintenance. By keeping the data-manipulating logic separate from the bits that handle the display, you make it much easier to change either the template or the underlying code without touching the other.

  • Models:

It helps to interact with your database and retrieve your objects’ information.It consists of a layer residing between the data and the application. The data itself can be stored in various types of database systems such as MySQL or even simple XML or Excel files.

  • Views:

Views are the visual representation of our web application, they are responsible for presenting the data that the Controller received from the Model. They can be easily built using the Blade template language that comes with Laravel or simply using plain PHP code. Blade is driven by template inheritance and sections. When Laravel renders these Views it examines first their file extension, and depending on it being either “.blade.php” or simply “.php”, determines if Laravel treats our View as a Blade template or not.

  • Controllers:

The function of a Controller is to handle requests and pass data from the Model to the Views. Thus a Controller can be considered as the link between our Model and Views.

 

Apart from this, routes are used to map URLs to designated controller actions, as shown in the figure below:

 Fig:MVC Pattern

 

  1. A request is made when a user enters a URL associated with your application.
  2. A route associated with that URL maps the URL to a controller action.
  3. That controller action leverages the necessary model to retrieve information from the database and then passes that data off to a view.
  4. And that view renders the final page.

 

 

  • Database:

1.Eloquent ORM
It is an object-relational mapper, It is named “Eloquent,” because it allows you to work with your database objects and relationships using an eloquent and expressive syntax. The Eloquent ORM is Laravel’s built-in ORM implementation. Every table in the database possess a corresponding Model through which the developer interact with said table.

 

2.Schema builder
The Laravel Schema class provides a database agnostic way of manipulating tables. It helps in managing all database related work such as creating or deleting tables and adding fields to an existing table. It works with a multitude of databases systems supported by Laravel and MySQL being the default one. The Schema class has the same API across all of these database systems.

 

3.Managing the database with Migrations
Migrations can be considered as a form of version control for our database. They allow us to change the database schema and describe and record all those specific changes in a migration file. Each Migration is usually associated with a Schema Builder to effort-lessly manage our application’s database. A migration can also be reverted or “rolled back” using the same said file.

       By Using terminal we can issue the following commands to create or drop tables in our database:

     Fig:Commands to create or drop tables in database

 

4.Seeders
The Seeder class lets us seed data into our tables.All seed classes are stored in the database/seeds directory. Seed classes may have any name you wish, but probably should follow some sensible convention, such as UsersTableSeeder, etc. By default, a DatabaseSeeder class is defined for you. From this class, you may use the call method to run other seed classes, allowing you to control the seeding order.

When the backend is empty we can populate it with some data by simply issuing the following command in the terminal:

$ php artisan db:seed

 

Attachments1

ASSIGNMENT : What is in vendor directory of Laravel ? MARKS : 5  DURATION : 5 minutes

SEE ALL Add a note
YOU
Add your Comment
 

Advanced Course Search Widget

Popular Courses

Course Categories

© PHPhelp. 2002 - 2018 All rights reserved.
X