Upload presentasi
Presentasi sedang didownload. Silahkan tunggu
Diterbitkan olehhardian hardian Telah diubah "5 tahun yang lalu
1
Introduction to Laravel framework “Love beautiful code? We do too.”
2
About Speaker Hardian [hardian@bki.co.id] PT Biro Klasifikasi Indonesia
3
Laravel (2011) V5.7 (2018) Taylor Otwell Laravel Horizon | Laravel Dusk | Laravel Echo | Valet | Lumen | and more….
4
Today Topic Architecture Routing Controller Model Views Migration Query Builder Eloquent Composer support
5
Architecture
7
Routing Default route files : routes/web.php and routes/api.php Available method : GET, POST, PUT, PATCH, DELETE, OPTIONS CSRF protection Using parameter(s) : Route::get('users/ {id} ', ['uses' => 'UserController@show]); Named route : Route::get('users/{id}', ['uses' =>UserController@show])-> name(‘show’) ; Grouping
8
Controller Default folder : app/Http/Controllers Connecting model and view (see the architecture) ‘Request’ handler : Illuminate\Http\Request ○ all() ○ only() ○ except() ○ json() ○ And more (https://laravel.com/api/5.5/Illuminate/Http/Request.html)
9
Controller
10
Return view response : return view('auth.login'); Compacting data to view $data['member'] = [ 'fatoni', 'kennan' ]; return view('member.index', compact('data')); Redirect to route : return redirect()->route('member.index');
11
Model Default folder : app Connecting app with database Awesome Eloquent
12
Model
13
Views Default folder : resources/views Blade templating (https://laravel.com/docs/5.5/blade)https://laravel.com/docs/5.5/blade
14
Views Easy to organizing
15
Views Easy to organizing
16
Migrations Default folder : database/migrations Build database from application Easily modify and share database schema Creating foreign key ( relationship )
17
Migrations CreateRolesTable CreatePermissionRoleTable
18
Migrations
19
Query Builder Get Data Query Builder : ○ $users = DB::table('users')->get(); SQL Query ○ $sql = "SELECT * FROM users”; Insert Data Query Builder : ○ $result = DB::table('users')->insert([‘colum1’ => ‘values1’, ‘column2’ => ‘values2’]); ○ $result = DB::table(users’)->insert($request->all()); SQL Query ○ INSERT INTO users (column1, column2.) VALUES (value1, value2)
20
Query Builder Update Data Query Builder : ○ $result = DB::table('users')->where(‘id’, ‘=’, 1)->update([‘colum1’ => ‘values1’, ‘column2’ => ‘values2’]); ○ $result = DB::table(users’) ->where(‘id’, ‘=’, 1) ->insert($request->all()); SQL Query ○ UPDATE users SET column1=value, column2=value2 WHERE id=1
21
Eloquent Awesome collections ( all(), create(), update(), etc ) Accessors & Mutators Easy managing and working with relationships Serializations
22
Eloquent Awesome collections ( all(), create(), update(), etc )
23
Eloquent Accessors & Mutators Accessor Mutator
24
Eloquent Easy managing and working with relationships ○ One To One ○ One To Many ○ Many To Many ○ Has Many Through ○ Polymorphic Relations ○ Many To Many Polymorphic Relations
25
Eloquent Easy managing and working with relationships ○ One To One Call it : $phone = User::find(1)->phone;
26
Eloquent Serializations ○ Serializing To Arrays ○ Serializing To JSON
27
Composer support
28
Terima Kasih
Presentasi serupa
© 2024 SlidePlayer.info Inc.
All rights reserved.