-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
904 lines (904 loc) · 24.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
<!DOCTYPE html>
<html lang="en">
<head>
<title>Laradebut #5 - 關於 CRUD 外的一點小事</title>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="node_modules/shower-ribbon/styles/screen-16x10.css">
</head>
<body class="shower list">
<header class="caption">
<h1>Laradebut #5 - 關於 CRUD 外的一點小事</h2>
<p>Cara Wang <[email protected]></p>
</header>
<section class="slide" id="cover">
<h2>Laradebut #5</h2>
<h3>關於 CRUD 外的一點小事</h3>
<div class="author">
<p>@author Cara Wang <[email protected]></p>
<p>@since 2016/11/29</p>
</div>
<img src="pictures/cover.jpg" class="cover">
<style>
#cover h2 {
margin: 14% 0 0;
padding: 10px;
color:#f0fcfe;
text-align:center;
font-size:60px;
border-width: 5px;
border-color: #f0fcfe;
border-top-style: solid;
border-bottom-style: solid;
}
#cover h3 {
margin: 18% 0 0;
color:#f0fcfe;
text-align:center;
font-size:30px;
}
.author {
margin-top: 20px;
margin-left: 248px;
color:#f0fcfe;
font-style:italic;
font-size:20px;
}
.author p {
line-height: 10px;
text-align:left;
}
.author p a {
color:#f0fcfe;
}
#cover img {
opacity: 0.9;
}
</style>
</section>
<section class="slide">
<img src="pictures/laraveltw.png" class="cover">
</section>
<section class="slide">
<img src="pictures/laraveltw1.png" class="cover">
</section>
<section class="slide">
<img src="pictures/cara.png" class="place left">
<div class="authorDesc">
<h2>PHP Developer</h2>
<ol>
<li class="next">2014/09 ~ now</li>
<li class="next"><a href="https://codeigniter.com/">CodeIgniter</a></li>
<li class="next"><a href="https://phalconphp.com/">Phalcon</a></li>
<li class="next"><a href="https://laravel.com/">Laravel</a></li>
</ol>
</div>
<style>
.authorDesc {
margin-left: 445px;
}
</style>
</section>
<section class="slide">
<h2>Why Do We Need Framework in PHP ?</h2>
<ol>
<li class="next">
Framework 幫忙做了哪些事 ?
<ol>
<li class="next">目錄結構</li>
</ol>
</li>
</ol>
<style>
ol ol {
list-style-type: disc;
}
.slide ol ol>li::before {
content: '';
}
</style>
</section>
<section class="slide">
<img src="pictures/codeigniterdir.png" class="cover">
<h2>CodeIgniter</h2>
</section>
<section class="slide">
<img src="pictures/phalcondir.png" class="cover">
<h2>Phalcon</h2>
<a href="https://github.com/phalcon/mvc">Phalcon MVC Examples</a>
</section>
<section class="slide">
<img src="pictures/laraveldir.png" class="cover">
<h2>Laravel</h2>
</section>
<section class="slide">
<h2>Why Do We Need Framework in PHP ?</h2>
<ol>
<li>
Framework 幫忙做了哪些事 ?
<ol>
<li>
目錄結構
<ol>
<li class="next">
方便協同合作: <span class="next">在同樣的規範與流程下寫程式</span>
</li>
</ol>
</li>
</ol>
</li>
</ol>
<style>
ol ol {
list-style-type: disc;
}
.slide ol ol>li::before {
content: '';
}
</style>
</section>
<section class="slide">
<img src="pictures/codeigniterdirmvc.png" class="cover">
<h2>CodeIgniter</h2>
</section>
<section class="slide">
<img src="pictures/phalcondirmvc.png" class="cover">
<h2>Phalcon</h2>
</section>
<section class="slide">
<img src="pictures/laraveldirmvc.png" class="cover">
<h2>Laravel</h2>
</section>
<section class="slide">
<h2>Why Do We Need Framework in PHP ?</h2>
<ol>
<li>
Framework 幫忙做了哪些事 ?
<ol>
<li>
目錄結構
<ol>
<li>方便協同合作: <span>在同樣的規範與流程下寫程式</span>
<ol>
<li class="next">未來的自己也是一個要合作的對象</li>
</ol>
</li>
</ol>
</li>
<li class="next">不用重複造輪子</li>
</ol>
</li>
</ol>
<style>
ol ol {
list-style-type: disc;
}
.slide ol ol>li::before {
content: '';
}
</style>
</section>
<section class="slide">
<img src="pictures/hellodemo.png" class="cover">
</section>
<section class="slide">
<figure>
<img src="pictures/codeigniterhello.png" class="cover">
<h3>CodeIgniter</h3>
</figure>
<style>
figure h3 {
margin-top: 50%;
color: #000;
font-size: 32px;
}
</style>
</section>
<section class="slide">
<figure>
<img src="pictures/laravelhello.png" class="cover">
<h3>Laravel</h3>
</figure>
<style>
figure h3 {
margin-top: 55%;
color: #000;
font-size: 32px;
}
</style>
</section>
<section class="slide">
<h2>Why Do We Need Framework in PHP ?</h2>
<ol>
<li>
Framework 幫忙做了哪些事 ?
<ol>
<li>
目錄結構
<ol>
<li>方便協同合作: <span>在同樣的規範下寫程式</span></li>
</ol>
</li>
<li>
不用重複造輪子
<ol>
<li class="next">專注在開發要提供的服務上</li>
<li class="next">加速完成速度</li>
</ol>
</li>
</ol>
</li>
</ol>
<style>
ol ol {
list-style-type: disc;
}
.slide ol ol>li::before {
content: '';
}
</style>
</section>
<section class="slide">
<h2>Why Do We Need Framework in PHP ?</h2>
<ol>
<li class="next">
依據自家需求來選擇 Framework
<ol>
<li class="next">擇你所愛,愛你所選</li>
<li class="next">享受 Framework 提供的功能,來讓合作與開發更快速</li>
<li class="next">跟你的 Framework 學習</li>
</ol>
</li>
</ol>
<style>
ol ol {
list-style-type: disc;
}
.slide ol ol>li::before {
content: '';
}
</style>
</section>
<section class="slide">
<h2>Why Do We Use Laravel ?</h2>
<ol>
<li class="next">跟你的 Framework 學習: <a href="http://www.slideshare.net/shengyou/phpconf-taiwan-2015-laravel-51-php">跟著 Laravel 5.1 一起成為更好的開發者</a>
<ol>
<li class="next">
快速的跟上語言版本特性 -> PHP7
<ol><li class="next">OCTOBER 26, 2016 - <a href="https://laravel-news.com/2016/10/laravel-v4-2-20/">V4.2.20 is now released with support for PHP 7.0</a></li></ol>
</li>
</ol>
</li>
</ol>
<style>
ol ol {
list-style-type: disc;
}
.slide ol ol>li::before {
content: '';
}
</style>
</section>
<section class="slide">
<img src="pictures/laravelgood1.png" class="cover">
</section>
<section class="slide">
<h2>Why Do We Use Laravel ?</h2>
<ol>
<li>跟你的 Framework 學習: <a href="http://www.slideshare.net/shengyou/phpconf-taiwan-2015-laravel-51-php">跟著 Laravel 5.1 一起成為更好的開發者</a>
<ol>
<li>
快速的跟上語言版本特性 -> PHP7
<ol><li>OCTOBER 26, 2016 - <a href="https://laravel-news.com/2016/10/laravel-v4-2-20/">V4.2.20 is now released with support for PHP 7.0</a></li></ol>
</li>
<li class="next">遵循標準: <a href="http://www.php-fig.org/psr/psr-2/">PSR-2</a> & <a href="http://www.php-fig.org/psr/psr-4/">PSR-4</a></li>
</ol>
</li>
</ol>
<style>
ol ol {
list-style-type: disc;
}
.slide ol ol>li::before {
content: '';
}
</style>
</section>
<section class="slide">
<img src="pictures/laravelgood2.png" class="cover">
</section>
<section class="slide">
<h2>Why Do We Use Laravel ?</h2>
<ol>
<li>跟你的 Framework 學習: <a href="http://www.slideshare.net/shengyou/phpconf-taiwan-2015-laravel-51-php">跟著 Laravel 5.1 一起成為更好的開發者</a>
<ol>
<li>
快速的跟上語言版本特性 -> PHP7
<ol><li>OCTOBER 26, 2016 - <a href="https://laravel-news.com/2016/10/laravel-v4-2-20/">V4.2.20 is now released with support for PHP 7.0</a></li></ol>
</li>
<li>遵循標準: <a href="http://www.php-fig.org/psr/psr-2/">PSR-2</a> & <a href="http://www.php-fig.org/psr/psr-4/">PSR-4</a></li>
<li class="next">整合套件管理工具: <a href="https://getcomposer.org/">Composer</a> & <a href="https://www.npmjs.com/">npm</a></li>
</ol>
</li>
</ol>
<style>
ol ol {
list-style-type: disc;
}
.slide ol ol>li::before {
content: '';
}
</style>
</section>
<section class="slide">
<img src="pictures/laravelgood3.png" class="cover">
</section>
<section class="slide">
<h2>Why Do We Use Laravel ?</h2>
<ol>
<li>跟你的 Framework 學習: <a href="http://www.slideshare.net/shengyou/phpconf-taiwan-2015-laravel-51-php">跟著 Laravel 5.1 一起成為更好的開發者</a>
<ol>
<li>
快速的跟上語言版本特性 -> PHP7
<ol><li>OCTOBER 26, 2016 - <a href="https://laravel-news.com/2016/10/laravel-v4-2-20/">V4.2.20 is now released with support for PHP 7.0</a></li></ol>
</li>
<li>遵循標準: <a href="http://www.php-fig.org/psr/psr-2/">PSR-2</a> & <a href="http://www.php-fig.org/psr/psr-4/">PSR-4</a></li>
<li>整合套件管理工具: <a href="https://getcomposer.org/">Composer</a> & <a href="https://www.npmjs.com/">npm</a></li>
<li class="next">非常棒的附加價值: 學習 Design Pattern</li>
</ol>
</li>
</ol>
<style>
ol ol {
list-style-type: disc;
}
.slide ol ol>li::before {
content: '';
}
</style>
</section>
<section class="slide">
<img src="pictures/laravelgood4.png" class="cover">
</section>
<section class="slide">
<h2>Why Do We Use Laravel ?</h2>
<ol>
<li class="next">安心的跟著 Laravel 一起成長</li>
</ol>
<style>
ol ol {
list-style-type: disc;
}
.slide ol ol>li::before {
content: '';
}
</style>
</section>
<section class="slide">
<img src="pictures/josh.jpeg" class="cover">
<h3>By <a href="https://github.com/codeguy">Josh Lockhart</a> @ 2016 PHPConf Taiwan</h3>
</section>
<section class="slide">
<h2>Introduction to Eloquent</h2>
<ol>
<li class="next">跟你的 Framework 學習: <span class="next">我可以跟 Laravel 學什麼 ?</span></li>
<li class="next">Laravel 提供的 <a href="https://en.wikipedia.org/wiki/Object-relational_mapping">ORM</a></li>
<li class="next">Why Do We Need ORM ?</li>
</ol>
<style>
ol ol {
list-style-type: disc;
}
.slide ol ol>li::before {
content: '';
}
</style>
</section>
<section class="slide">
<img src="pictures/orm.png" class="cover">
</section>
<section class="slide">
<h2>Introduction to Eloquent</h2>
<ol>
<li>Laravel 提供的 <a href="https://en.wikipedia.org/wiki/Object-relational_mapping">ORM</a></li>
<li>
Why Do We Need ORM ?
<ol>
<li class="next">Keep it simple</li>
<li class="next">方便協同合作</li>
<li class="next">安全性考量: <span class="next"><a href="https://en.wikipedia.org/wiki/SQL_injection">SQL Injection</a></span></li>
</ol>
</li>
</ol>
<style>
ol ol {
list-style-type: disc;
}
.slide ol ol>li::before {
content: '';
}
</style>
</section>
<section class="slide">
<img src="pictures/sqlinjection.png" class="cover">
</section>
<section class="slide">
<h2>Introduction to Eloquent</h2>
<ol>
<li class="next">
如何使用
<ol>
<li class="next">你有一個 Model</li>
</ol>
</li>
</ol>
<pre class="next">
<code><?php</code>
<code>namespace App;</code>
<code>use <mark>Illuminate\Database\Eloquent\Model</mark>;</code>
<code>class Product extends <mark>Model</mark></code>
<code>{</code>
<code>}</code>
</pre>
<style>
ol ol {
list-style-type: disc;
}
.slide ol ol>li::before {
content: '';
}
</style>
</section>
<section class="slide">
<h2>Introduction to Eloquent</h2>
<ol>
<li>如何使用
<ol>
<li class="next">你開始使用 Model</li>
</ol>
</li>
</ol>
<pre class="next">
<code>Product::select('name', 'price')</code>
<code> ->where('discount', '<', 1)</code>
<code> ->first();</code>
</pre>
<style>
ol ol {
list-style-type: disc;
}
.slide ol ol>li::before {
content: '';
}
</style>
</section>
<section class="slide">
<h2>Introduction to Eloquent</h2>
<ol>
<li>如何使用</li>
<ol>
<li class="next">實際上組出來的 SQL</li>
<li class="next">可以透過 <mark>->toSql()</mark> 取得 ORM 實際組出來的 SQL</li>
<li class="next">可以透過 <mark>->getBindings()</mark> 取得 傳給 SQL 的變數</li>
</ol>
</li>
</ol>
<pre class="next">
<code>SELECT `name`, `price`</code>
<code>FROM `product`</code>
<code>WHERE `discount` < 1;</code>
</pre>
<style>
ol ol {
list-style-type: disc;
}
.slide ol ol>li::before {
content: '';
}
</style>
</section>
<section class="slide">
<h2>Introduction to Eloquent</h2>
<pre class="next smallCode">
<code>CREATE TABLE `products` (</code>
<code> `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '商品流水號',</code>
<code> `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '商品名稱',</code>
<code> `brand` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '品牌',</code>
<code> `type` varchar(255) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '商品型號',</code>
<code> <mark>`price`</mark> double(8,2) NOT NULL,</code>
<code> `discount` double(8,2) NOT NULL DEFAULT '1.00',</code>
<code> `created_at` timestamp NULL DEFAULT NULL,</code>
<code> `updated_at` timestamp NULL DEFAULT NULL,</code>
<code> PRIMARY KEY (`id`),</code>
<code>) ENGINE=InnoDB AUTO_INCREMENT=1058 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;</code>
</pre>
<style>
ol ol {
list-style-type: disc;
}
.slide ol ol>li::before {
content: '';
}
.smallCode code {
font-size: 18px;
}
</style>
</section>
<section class="slide">
<h2>Introduction to Eloquent</h2>
<ol>
<li class="next">價格要乘以折扣數: <span class="next">你可以這樣寫</span>
<ol>
<li class="next">分別取出 <mark>price</mark> 和 <mark>discount</mark></li>
<li class="next">相乘後在顯示到頁面上</li>
<li class="next">還要小心記得要做四捨五入</li>
</ol>
</li>
<li class="next">但你用的是 Laravel, 所以你有更好的選擇
<ol>
<li class="next">使用 Accessors</li>
</ol>
</li>
</ol>
</section>
<section class="slide">
<pre>
<code>public function getPriceAttribute()</code>
<code>{</code>
<code> $price = (float)$this->attributes['price'];</code>
<code> $discount = (float)$this->attributes['discount'];</code>
<code> return (int) ceil($price * $discount);</code>
<code>}</code>
</pre>
</section>
<section class="slide">
<img src="pictures/accessor.png" class="cover">
</section>
<section class="slide">
<h2>Introduction to Eloquent</h2>
<ol>
<li class="next">
如果 <mark>discount</mark> 存錯值,問題就大條了!
<ol>
<li class="next">不小心存成大於 <mark>1</mark> 的值</li>
<li class="next">公司規定折扣數不會低於五折</li>
</ol>
</li>
<li class="next">你可以這樣寫
<ol>
<li class="next">寫一個 <mark>checkValidDiscount(...)</mark> 的 Helper function</li>
<li class="next">每次存入前就檢查一下</li>
</ol>
</li>
<li class="next">但你用的是 Laravel, 所以你有更好的選擇
<ol>
<li class="next">使用 Mutator</li>
</ol>
</li>
</ol>
</section>
<section class="slide">
<pre>
<code>public function setDiscountAttribute($value)</code>
<code>{</code>
<code> if ($value > 1) {</code>
<code> $value = 1;</code>
<code> } elseif ($value < 0.5) {</code>
<code> $value = 0.5;</code>
<code> }</code>
<code> </code>
<code> $this->attributes['discount'] = $value;</code>
<code>}</code>
</pre>
</section>
<section class="slide">
<img src="pictures/mutator.png" class="cover">
</section>
<section class="slide">
<h2>Introduction to Eloquent</h2>
<ol>
<li class="next">其他 Mutators 的例子</li>
<li class="next">型號是顏色的話,結尾一定要是 <mark>色</mark></li>
</ol>
</section>
<section class="slide">
<pre class="smallCode">
<code>public function setTypeAttribute($value)</code>
<code>{</code>
<code> if (((int)stripos($value, '色') - 1) !== mb_strlen($value)</code>
<code> && in_array($value, self::$colors)) {</code>
<code> $value .= '色';</code>
<code> }</code>
<code> </code>
<code> $this->attributes['type'] = $value;</code>
<code>}</code>
</pre>
<style>
.smallCode code {
font-size: 23px;
}
</style>
</section>
<section class="slide">
<img src="pictures/mutator1.png" class="cover">
</section>
<section class="slide">
<h2>Introduction to Eloquent</h2>
<ol>
<li class="next">其他 Accessors 的例子</li>
<li class="next">
品名包含: <span class="next">【品牌】</span><span class="next">品名</span><span class="next"> - 型號</span>
</li>
</ol>
</section>
<section class="slide">
<h2>Introduction to Eloquent</h2>
<ol>
<li class="next">你可以這樣寫
<ol>
<li class="next"><mark>getProductName(...)</mark> 的 Helper function</li>
<li class="next">從 Model 拿出 <mark>name</makr>、<mark>brand</makr>、<mark>type</mark></li>
<li class="next">一一丟進 <mark>getProductName(...)</mark> 中組出 【品牌】品名 - 型號</li>
</ol>
</li>
<li class="next">但你用的是 Laravel, 所以你有更好的選擇
<ol>
<li class="next">使用 Accessors</li>
</ol>
</li>
</ol>
</section>
<section class="slide">
<pre>
<code>public function getFullNameAttribute()</code>
<code>{</code>
<code> return sprintf(</code>
<code> '【%s】%s - %s',</code>
<code> $this->attributes['brand'],</code>
<code> $this->attributes['name'],</code>
<code> $this->attributes['type']</code>
<code> );</code>
<code>}</code>
</pre>
</section>
<section class="slide">
<img src="pictures/accessor1.png" class="cover">
</section>
<section class="slide">
<h2>Introduction to Eloquent</h2>
<ol>
<li class="next">
可以利用 <mark>Accessors</mark> 設定不屬於資料表本身的欄位
<ol>
<li class="next">看起來好像很好,只是...
<li class="next">難道我每次都要自己把 <mark>$xxx->fullName</mark> 放進要顯示的地方嗎?</li>
<li class="next">別怕!你需要的是 <span class="next"><mark>$appends</makr></span></li>
</ol>
</li>
</ol>
</section>
<section class="slide">
<pre>
<code>protected $appends = ['fullName'];</code>
</pre>
</section>
<section class="slide">
<img src="pictures/appends.png" class="cover">
</section>
<section class="slide">
<h2>Introduction to Eloquent</h2>
<ol>
<li class="next">
其他關於 Eloquent 的小事
<ol>
<li class="next">設定 <mark>attributes</mark> 預設值</li>
</ol>
</li>
</ol>
</section>
<section class="slide">
<pre>
<code>protected $attributes = [</code>
<code> 'brand' => 'Laradebut'</code>
<code> 'type' => ''</code>
<code>];</code>
</pre>
</section>
<section class="slide">
<h2>Introduction to Eloquent</h2>
<ol>
<li>
其他關於 Eloquent 的小事
<ol>
<li>設定 <mark>attributes</mark> 預設值</li>
<li class="next">
設定 <mark>casts</mark> 資料型別
<ol>
<li class="next"><mark>price</mark> 必須是 integer</li>
</ol>
</li>
</ol>
</li>
</ol>
</section>
<section class="slide">
<pre>
<code>protected $casts = [</code>
<code> 'price' => 'int',</code>
<code> 'discount' => 'float'</code>
<code>];</code>
</pre>
</section>
<section class="slide">
<h2>Introduction to Eloquent</h2>
<ol>
<li>
其他關於 Eloquent 的小事
<ol>
<li>設定 <mark>attributes</mark> 預設值</li>
<li>
設定 <mark>casts</mark> 資料型別
<ol>
<li><mark>price</mark> 必須是 integer</li>
<li class="next">有個小問題兒: 如果你用了 Mutator,設定 <mark>$casts</mark> 就會無效 <code>in version: 5.3.24</code></li>
</ol>
</li>
</ol>
</li>
</ol>
</section>
<section class="slide">
<img src="pictures/mutatorAndCasts.png" class="cover">
<h3><code>Illuminate/Database/Eloquent/Model</code></h3>
</section>
<section class="slide">
<h2>Introduction to Eloquent</h2>
<ol>
<li>
其他關於 Eloquent 的小事
<ol>
<li>設定 <mark>attributes</mark> 預設值</li>
<li>
設定 <mark>casts</mark> 資料型別
<ol>
<li><mark>price</mark> 必須是 integer</li>
</ol>
</li>
<li class="next">
設定 <mark>CREATED_AT</mark> 和 <mark>UPDATED_AT</mark>
</li>
</ol>
</li>
</ol>
</section>
<section class="slide">
<pre>
<code>const CREATED_AT = 'createdAt';</code>
<code>const UPDATED_AT = 'updatedAt';</code>
</pre>
</section>
<section class="slide">
<h2>Introduction to Eloquent</h2>
<ol>
<li>
其他關於 Eloquent 的小事
<ol>
<li>設定 <mark>attributes</mark> 預設值</li>
<li>
設定 <mark>casts</mark> 資料型別
<ol>
<li><mark>price</mark> 必須是 integer</li>
</ol>
</li>
<li>
設定 <mark>CREATED_AT</mark> 和 <mark>UPDATED_AT</mark>
<ol>
<li class="next">migration 得要自己設定</li>
</ol>
</li>
</ol>
</li>
</ol>
</section>
<section class="slide">
<h3 class="next">原本:</h3>
<pre class="next">
<code>$table->timestamps();</code>
</pre>
<h3 class="next">更動 <mark>CREATED_AT</mark> 和 <mark>UPDATED_AT</mark>:</h3>
<pre class="next">
<code>$table->timestamp('createdAt')->nullable();</code>
<code>$table->timestamp('updatedAt')->nullable();</code>
</pre>
<style>
h3 {
margin-bottom: 15px;
}
</style>
</section>
<section class="slide">
<h2>Why Do We Use Laravel ?</h2>
<ol>
<li class="next">使用並享受 Framework 帶來的好處</li>
<li class="next">跟你的 Framework 學習</li>
<li class="next">練習看 Source Code</li>
<li class="next"><a href="https://github.com/CaraWang/laradebut-5-demo">Demo Code</a></li>
</ol>
</section>
<section class="slide">
<h2>Q & A</h2>
<img src="pictures/end.jpg" alt="" class="cover">
<style>
#end h2 {
margin: 350px 0 0;
padding: 10px;
color:#DB2F13;
text-align:right;
font-size:60px;
}
</style>
</section>
<section class="slide">
<h2>2015/09 ~ 2016/12</h2>
</section>
<section class="slide">
<h3>2016/03</h3>
<img src="pictures/cnyesmwebnews.jpg" class="cover">
</section>
<section class="slide">
<img src="pictures/cnyesmwebmarket.jpg" class="cover">
</section>
<section class="slide">
<img src="pictures/cnyesmwebsearch.jpg" class="cover">
</section>
<section class="slide">
<h3>2016/05</h3>
<img src="pictures/cnyesappnews.jpg" class="cover">
</section>
<section class="slide">
<img src="pictures/cnyesappmarket.jpg" class="cover">
</section>
<section class="slide">
<img src="pictures/cnyesappmarket1.jpg" class="cover">
</section>
<section class="slide">
<h3 class="release">2016/08</h3>
<img src="pictures/cnyesnews.png" class="cover">
<style>
.release {
margin-top: 50%;
color: #333;
}
</style>
</section>
<section class="slide">
<h3 class="release">2016/12</h3>
<img src="pictures/cnyesstock.png" class="cover">
<style>
.release {
margin-top: 50%;
color: #333;
}
</style>
</section>
<section class="slide">
<h2>如果你對我們有興趣,歡迎來找彩蛋</h2>
</section>
<section class="slide" id="end">
<img src="pictures/cnyeshire.png" class="cover">
</section>
<p class="badge">
<a href="https://github.com/CaraWang/2016-laradebut-eloquent">Fork me on GitHub</a>
</p>
<!--
To hide progress bar from entire presentation
just remove “progress” element.
-->
<div class="progress"></div>
<script src="node_modules/shower-core/shower.min.js"></script>
<!-- Copyright © 2015 Yours Truly, Famous Inc. -->
<!-- Photos by John Carey, fiftyfootshadows.net -->
</body>
</html>