getting_started_with_laravel

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
getting_started_with_laravel [04.12.2020 11:19] – [dump / dump and die] Pascal Sutergetting_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 ''DELETE'' so we need to use a blade function ''@method('DELETE')'' just after the form tag.  **processing delete requests** are like posts, but we can't set the form method to ''DELETE'' so we need to use a blade function ''@method('DELETE')'' just after the form tag. 
  
 +**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 ''session()'' helper which will save new key=>value pairs when it is passed an array as argument like ''session(['newkey',$someVar])'' for example. to get ''$someVar'' back we would use the helper like ''$someVar=session('newkey')''. alternatively, we can use an instance of the ''Request'' class and the ''put()'' and ''get()'' functions for the ''session'' property like so: ''$request->session()->put('tmpfiles',$tmpfiles);'' and vice versa ''$tmpfiles = $request->session()->get('tmpfiles',[]);'' notice a nice feature of the ''get()'' method: we can pass a default value as a second argument which will be returned in case the session variable is not set. that's pretty helpful. Session variables are also available in blades by using the ''session()'' helper like above. <br>
 +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 ''get()'' function but now use a ''flash()'' method, that's it. 
 ===== 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. 
  • getting_started_with_laravel.txt
  • Last modified: 04.12.2020 11:44
  • by Pascal Suter