Eastern Enterprise B.V. • Working in Web development since 12 years, mainly in PHP. • Twitter: @kapilsharmainfo • Facebook: /kapilsharmainfo • LinkedIn: kapilsharmainfo • Web: kapilsharma.info • Slides: speakerdeck.com/ kapilsharma 2
use plain PHP in blade (Unlike most other template engines) • Parsed into plain php and cached, meaning zero overhead. • File name: *.blade.php • Mostly stored in resources/views 19
(count($records)>1) I have multiple records! @else I don't have any records! @endif @unless (Auth::check()) You are not signed in. @endunless @if (!Auth::check()) You are not signed in. @endif
Show a list of all of the application's users. * * @return Response */ public function index() { $users = DB::select('select * from users where active = ?', [1]); return view('user.index', ['users' => $users]); } } $results = DB::select('select * from users where id = :id', ['id' => 1]);
Simple Active Record implementation • Each DB table have corresponding Model. • Model used to do CRUD operation on table. • Follows ‘Convention over configuration’ principle. 28
What is active users? This question is answered by business logic. Where should we place business logic? Controller? Against DRY. Can duplicate code. Views? Obviously NO. Models? No, model means data. BL is not data. Service Layer
Service Fetch data call view Response Seems OK? No, we still have a problem. Repository SQL getAdmin Users() function getAdminUser() { $this->repository->getAdminUser(); } View
Defines the set of methods, must be provided by implementing class. In simple words: Contract. "programming to an interface" means focusing your design on what the code is doing, not how it does it.
• Bootstrapping = registering. • We register services, event listeners, middleware, routes etc. • To do that, we use ‘providers’ array in ‘config/ app.php’ file. 47