Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| getting_started_with_laravel [03.12.2020 15:43] – [Form validation] Pascal Suter | getting_started_with_laravel [04.12.2020 11:44] (current) – [Basics] Pascal Suter | ||
|---|---|---|---|
| Line 104: | Line 104: | ||
| **processing delete requests** are like posts, but we can't set the form method to '' | **processing delete requests** are like posts, but we can't set the form method to '' | ||
| + | **sessions and flashing data** in laravel we can either store data into our session, like in normal php.. we can do this either via the '' | ||
| + | a specialty in laravel is, that we can **flash** data to a session. flashing means, that the data will only remain in the session for the next request. after that it will either be unset or we need to **reflash** to keep the flashed variables. to flash a variable to a session, we do the same as above with the '' | ||
| ===== Relations ===== | ===== Relations ===== | ||
| relations are defined in the Model by adding a new public function to it. | relations are defined in the Model by adding a new public function to it. | ||
| Line 169: | Line 171: | ||
| * in addition to bringing the user back to the form, laravel will provide an '' | * in addition to bringing the user back to the form, laravel will provide an '' | ||
| * even better, there is a '' | * even better, there is a '' | ||
| - | + | * you also get a '' | |
| - | here's an example part of a blade with a form that will show some info if the validation fails: | + | here's an example part of a (bootstrap based) |
| <code html> | <code html> | ||
| Line 183: | Line 185: | ||
| <div class=" | <div class=" | ||
| <label for=" | <label for=" | ||
| - | <input type=" | + | <input type=" |
| <div class=" | <div class=" | ||
| </ | </ | ||
| Line 190: | Line 192: | ||
| ===== Tricks ===== | ===== Tricks ===== | ||
| + | ==== dump / dump and die ==== | ||
| + | this has to be the first tip :) .. there is a helper function called '' | ||
| + | |||
| + | you may not always want to stop the execution, so another helper called '' | ||
| + | |||
| + | to use those helpers in a blade, there are special blade syntax helpers available which make it even easier: | ||
| + | < | ||
| + | for example dumps all defined variables. there is also a '' | ||
| + | |||
| + | note that using < | ||
| ==== Create Model + Controller + Migration all in one step ==== | ==== Create Model + Controller + Migration all in one step ==== | ||
| artisan make:model Pizza -mc | artisan make:model Pizza -mc | ||
| Line 224: | Line 236: | ||
| @extends(' | @extends(' | ||
| </ | </ | ||
| - | and in the layout you would then simply use '' | + | and in the layout you would then simply use < |
| === 2.) create a mini-section === | === 2.) create a mini-section === | ||