Laravel (Basic) Spirits @ https ://laravel.com Expressive, beautiful syntax. Value elegance, simplicity, and readability? You’ll fit right in. Laravel is designed for people just like. If you need help getting started, check out Laracasts and our great documentation. ࡔຊ߶ @sakamoto03 (Sodick Co., Ltd.) ͙͔͢ΔʂLaravel PHP ΧϯϑΝϨϯεؔ 8 / 41
Laravel 4.2 Introduction https ://laravel.com/docs/4.2/introduction Laravel Philosophy (ࢥ) Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as authentication, routing, sessions, and caching. Expressive(දݱʹΈ) + Elegant(؆ܿʹɺ͖ͬ͢Γ) ϓϩάϥϜ͕ॻ͚ͯ + Enjoyable(ָ͘͠) + Creative(తˍಠతʹ) ͳࣄ === Development(։ൃ) by Laravel Expressive + Elegant + Enjyoable + Creative = Artisan 3E + 1C ͳΣϒ։ൃΛ Laravel Ͱͯ͠Έ·ͤΜ͔ʁ Expressive + Elegant + Enjyoable + Creative = 3E + 1C ࡔຊ߶ @sakamoto03 (Sodick Co., Ltd.) ͙͔͢ΔʂLaravel PHP ΧϯϑΝϨϯεؔ 9 / 41
ͳͥɺ3E+1C ͳ։ൃ͕Ͱ͖Δͷ͔ʁ Laravel Philosophy (ࢥ) https ://laravel.com/docs/4.2/introduction Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as authentication, routing, sessions, and caching. ຖճॻ͘Α͏ͳڞ௨ػೳΛ؆ૉԽ (Easy) ͍ͯ͠Δ ͦͷͨΊɺશମΛߏ͢Δ͜ͱʹ࣌ؒΛ͚͞Δ ΞʔΩςΫνϟʹઐ೦Ͱ͖Δ ޙपΓʹͳΓ͕ͪͳ࡞ۀͷ࣌ؒ֬อ Software Design, Refactoring, Testing, Documentation Artisan = Art = Architecture ࡔຊ߶ @sakamoto03 (Sodick Co., Ltd.) ͙͔͢ΔʂLaravel PHP ΧϯϑΝϨϯεؔ 10 / 41
Laravel Validation @ https ://laravel.com/docs/5.4/validation /∗∗ ∗ Store a new blog post . ∗ ∗ @param Request $request ∗ @return Response ∗/ public function store ( Request $request ) { $this −>v a l id at e ( $request , [ ’ t i t l e ’ => ’ required | unique : posts |max:255 ’ , ’ body ’ => ’ required ’ , ] ) ; / / The blog post i s valid , store in datebase } ࡔຊ߶ @sakamoto03 (Sodick Co., Ltd.) ͙͔͢ΔʂLaravel PHP ΧϯϑΝϨϯεؔ 18 / 41
Active Record Validation @ RAILS GUIDES https ://railsguides.jp/active_record_vlidations.html class Person < ActiveRecord : : Base validates : name, presence : true end Person . create (name: " John Doe " ) . v a l i d ? # => true Person . create (name: n i l ) . v a l i d ? # => false ެࣜղઆ ͜ͷόϦσʔγϣϯͰ Person ʹ name ଐੑ͕ͳ͍߹ʹ ແޮͰ͋Δ͜ͱΛΒͤ·͢ɻ @Laravel ’name’ => ’present’ ࡔຊ߶ @sakamoto03 (Sodick Co., Ltd.) ͙͔͢ΔʂLaravel PHP ΧϯϑΝϨϯεؔ 20 / 41
spring Validaing Form Input @ https ://spring.io/guides/gs/validating-form-input/ package hello ; import javax . v a l i d a t i o n . constraints . Min ; import javax . v a l i d a t i o n . constraints . NotNull ; import javax . v a l i d a t i o n . constraints . Size ; public class PersonForm { @NotNull @Size( min=2 , max=30) pri vat e String name; @NotNull @Min(18) pri vat e Integer age ; public String getName ( ) { return t h i s .name; } ࡔຊ߶ @sakamoto03 (Sodick Co., Ltd.) ͙͔͢ΔʂLaravel PHP ΧϯϑΝϨϯεؔ 22 / 41
Spring Validaing Form Input @ https ://spring.io/guides/gs/validating-form-input/ Java Annotation import javax . v a l i d a t i o n . constraints . Min ; import javax . v a l i d a t i o n . constraints . NotNull ; import javax . v a l i d a t i o n . constraints . Size ; public class PersonForm { @NotNull @Size( min=2 , max=30) priv ate String name; @NotNull @Min(18) priv ate Integer age ; @Spring Annotation Λ༻͍ͯهड़ @Laravel ’name’ => ’required|min :2|max :30’, ’age’ => ’required|numeric|min :18’, ࡔຊ߶ @sakamoto03 (Sodick Co., Ltd.) ͙͔͢ΔʂLaravel PHP ΧϯϑΝϨϯεؔ 23 / 41
ANGULAR Form Validation @ https ://angular.io/guide/gs/validation < label f o r ="name">Name</ label > <input type =" t e x t " id ="name" class =" form−co nt ro l " required minlength ="4" maxlength ="24" name="name" [ ( ngModel ) ] = " hero .name" #name="ngModel"> <div ∗ ngIf ="name. errors && (name. d i r t y | | name. touched ) " class =" a l e r t a l e r t −danger"> <div [ hidden ] = " ! name. errors . required "> Name i s required </ div > <div [ hidden ] = " ! name. errors . minlength "> Name must be least 4 characters long . </ div > <div [ hidden ] = " ! name. errors . maxlength"> Name cannot be more than 24 characters long . </ div > </ div > ࡔຊ߶ @sakamoto03 (Sodick Co., Ltd.) ͙͔͢ΔʂLaravel PHP ΧϯϑΝϨϯεؔ 24 / 41
ANGULAR Form Validation @ https ://angular.io/guide/gs/validation <div ∗ ngIf ="name. errors && . . . class =" a l e r t a l e r t −danger"> <div [ hidden ] = " ! name. errors . required "> Name i s required </ div > <div [ hidden ] = " ! name. errors . minlength "> Name must be least 4 characters long . </ div > <div [ hidden ] = " ! name. errors . maxlength"> Name cannot be more than 24 characters long . </ div > . . . @Laravel Customizing The Error Messages public function messages ( ) { return [ ’name. required ’ => ’Name i s required ’ , ’name. min ’ => ’Name must be least 4 characters long ’ , ’name.max ’ => ’Name cannot be more than 24 characters ’ , ] ; } ࡔຊ߶ @sakamoto03 (Sodick Co., Ltd.) ͙͔͢ΔʂLaravel PHP ΧϯϑΝϨϯεؔ 26 / 41
ANGULAR Form Validation @ https ://angular.io/guide/gs/validation <div ∗ ngIf ="name. errors && . . . class =" a l e r t a l e r t −danger"> <div [ hidden ] = " ! name. errors . required "> Name i s required </ div > <div [ hidden ] = " ! name. errors . minlength "> Name must be least 4 characters long . </ div > <div [ hidden ] = " ! name. errors . maxlength"> Name cannot be more than 24 characters long . </ div > . . . @Laravel Custom Error Messages $messages = [ ’name. required ’ => ’Name i s required ’ , ’name. min ’ => ’Name must be least 4 characters long ’ , ’name.max ’ => ’Name cannot be more than 24 characters ’ , ] ; $ v a l i d a t o r = Validator : : make( $input , $rules , $messages ) ; ࡔຊ߶ @sakamoto03 (Sodick Co., Ltd.) ͙͔͢ΔʂLaravel PHP ΧϯϑΝϨϯεؔ 27 / 41
ANGULAR Form Validation @ https ://angular.io/guide/gs/validation <div ∗ ngIf ="name. errors && . . . class =" a l e r t a l e r t −danger"> <div [ hidden ] = " ! name. errors . required "> Name i s required </ div > <div [ hidden ] = " ! name. errors . minlength "> Name must be least 4 characters long . </ div > <div [ hidden ] = " ! name. errors . maxlength"> Name cannot be more than 24 characters long . </ div > . . . @Laravel Specifying Custom Message In Language Files resources/lang/en/validation.php ’ custom ’ => [ ’name ’ => [ ’ required ’ => ’Name i s required ’ , ’ min ’ => ’Name must be least 4 characters long ’ , ’max ’ => ’Name cannot be more than 24 characters ’ , ] , ] , ࡔຊ߶ @sakamoto03 (Sodick Co., Ltd.) ͙͔͢ΔʂLaravel PHP ΧϯϑΝϨϯεؔ 28 / 41
CakePHP Core Validation Rules @ https ://book.cakephp.org/3.0/en/core-libraries/validation.html $ v a l i d a t o r = new Validator ( ) ; $ v a l i d a t o r −>add ( ’ t i t l e ’ , ’ minLength ’ , [ ’ rule ’ => [ ’ minLength ’ , 10] ] ) −>add ( ’ rating ’ , ’ validValue ’ , [ ’ rule ’ => [ ’ range ’ , 1 , 5] ] ) ; @Laravel $this −>v a l i d a t e ( $request , [ ’ t i t l e ’ => ’ min :10 ’ , ’ rating ’ => ’ between :1 ,5 ’ , ] ) ; ࡔຊ߶ @sakamoto03 (Sodick Co., Ltd.) ͙͔͢ΔʂLaravel PHP ΧϯϑΝϨϯεؔ 29 / 41
CakePHP Core Validation Rules @ https ://book.cakephp.org/3.0/en/core-libraries/validation.html $ v a l i d a t o r = new Validator ( ) ; $ v a l i d a t o r −>add ( ’ t i t l e ’ , ’ minLength ’ , [ ’ rule ’ => [ ’ minLength ’ , 10] ] ) −>add ( ’ rating ’ , ’ validValue ’ , [ ’ rule ’ => [ ’ range ’ , 1 , 5] ] ) ; @Laravel $ v a l i d a t o r = Validator : : make( $request −> a l l ( ) , [ ’ t i t l e ’ => ’ min :10 ’ , ’ rating ’ => ’ between :1 ,5 ’ , ] ) ; ࡔຊ߶ @sakamoto03 (Sodick Co., Ltd.) ͙͔͢ΔʂLaravel PHP ΧϯϑΝϨϯεؔ 30 / 41
CakePHP Validation @ https ://book.cakephp.org/3.0/en/core-libraries/validation.html $ v a l i d a t o r −>requirePresence ( ’ t i t l e ’ ) −>notEmpty ( ’ t i t l e ’ , ’ Please f i l l t h i s f i e l d ’ ) −>add ( ’ t i t l e ’ , [ ’ length ’ => [ ’ rule ’ => [ ’ minLength ’ , 10] , ’message ’ => ’ T i t l e s need to be at least 10 characters long ’ , ] ] ) ; @Laravel @validate part ’ t i t l e ’ => ’ present | required | min :10 ’ @messeage part ’ t i t l e . required ’ => ’ Please f i l l t h i s f i e l d ’ ’ t i t l e . min ’ => ’ T i t l e s need to be at least 10 characters long ’ ࡔຊ߶ @sakamoto03 (Sodick Co., Ltd.) ͙͔͢ΔʂLaravel PHP ΧϯϑΝϨϯεؔ 31 / 41
CakePHP Validation @ https ://book.cakephp.org/3.0/en/core-libraries/validation.html $ v a l i d a t o r −>requirePresence ( ’ t i t l e ’ ) −>notEmpty ( ’ t i t l e ’ , ’ Please f i l l t h i s f i e l d ’ ) −>add ( ’ t i t l e ’ , [ ’ length ’ => [ ’ rule ’ => [ ’ minLength ’ , 10] , ’message ’ => ’ T i t l e s need to be at least 10 characters long ’ , ] ] ) −>allowEmpty ( ’ published ’ ) −>add ( ’ published ’ , ’ boolean ’ , [ ’ rule ’ => ’ boolean ’ ] ) −>requirePresense ( ’ body ’ ) −>add ( ’ body ’ , ’ length ’ , [ ’ rule ’ => [ ’ minLength ’ , 50] , ’message ’ => ’ A r t i c l e s must have a s u b s t a n t i a l body . ’ ] ) ; ࡔຊ߶ @sakamoto03 (Sodick Co., Ltd.) ͙͔͢ΔʂLaravel PHP ΧϯϑΝϨϯεؔ 32 / 41
Available Laravel Validation Rules Accepted Dimensions(Image Files) Numeric Active URL Distinct Present After(Date) E-Mail Regular Expression After Or Equal (Date) Exists (Database) Required Alpha File Required If Alpha Dash Filled Required Unless Alpha Numeric Image (File) Required With Array In Required With All Before(Date) In Array Required Without Before Or Equal(Date) Integer Required Without Between IP Address Same Boolean JSON Size Confirmed Max String Date MIME Types Timezone Date Format MIME Type By File Extension Unique (Database) Different Min URL Digits Nullable Digits Between Not in ࡔຊ߶ @sakamoto03 (Sodick Co., Ltd.) ͙͔͢ΔʂLaravel PHP ΧϯϑΝϨϯεؔ 35 / 41