Routes


api.php dan web.php

In web.php, route ‘/’, leads to a controller ‘ContentsController’ with function named ‘home’

Browse to ‘ContentsController’ ini ada di repository app→Http→Controllers

In ‘ContentsController’ public function home will be executed, and will return the result into a view called ‘contents/home’.

Explore ‘contents/home’ in repository: files→resources→view→contents with filename home.blade.php

This is the frontpage of the URL



For Model component, it is the representation of database and table. From the homepage click Clients. This will lead us to a route called ‘clients’

In repository, from file→routes→web.php. You will find routes of ‘/clients’

Routes ‘clients’ will be dihandled by ‘ClientController’ with function ‘index’.
Explore files→app→Http→Controllers→ClientController.php, we will find function index() inside. Inside function index(), there is a command of select all → all() using Model named ‘client’. All() is a system function of SQL query “select * from”

Model named client files will be find in →app→client.php

in client.php ini, function reservation() wont be run, Only system function all() equivalent to “select * from” a table name

In Laravel framework, the file name of model (in this case ‘client’) is representing a table name in database called ‘clients’ (same name as model file name with ‘s’ or plural)

This mapping process of Model with Database is called ORM (Object Relation mapping)


back to the function called index(), the query result of system function all() from table clients (equivalent with select * from clients) will be stored in variable array called $data[’clients’], and will be shown in a View called ‘client/data’ with all values in inside $data array:
