<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Model &#8211; The Eternal Path</title>
	<atom:link href="https://arasan.de/tag/model/feed/" rel="self" type="application/rss+xml" />
	<link>https://arasan.de</link>
	<description>Arasan.de</description>
	<lastBuildDate>Tue, 13 Sep 2022 10:12:59 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.2</generator>

<image>
	<url>https://arasan.de/wp-content/uploads/2024/10/triquetra-512x512-1.png</url>
	<title>Model &#8211; The Eternal Path</title>
	<link>https://arasan.de</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Laravel &#8211; Eintrag mit Eloquent aus Datenbank löschen</title>
		<link>https://arasan.de/laravel-eintrag-mit-eloquent-aus-datenbank-loeschen/</link>
		
		<dc:creator><![CDATA[«Æ»]]></dc:creator>
		<pubDate>Tue, 13 Sep 2022 10:12:59 +0000</pubDate>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Eloquent]]></category>
		<category><![CDATA[Laravel]]></category>
		<category><![CDATA[Model]]></category>
		<category><![CDATA[Tabelle]]></category>
		<guid isPermaLink="false">https://arasan.de/?p=518</guid>

					<description><![CDATA[Mit der &#8222;destroy()&#8220; Methode lässt sich mit Eloquent ein Eintrag aus der Datenbank-Tabelle löschen:]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Mit der &#8222;destroy()&#8220; Methode lässt sich mit Eloquent ein Eintrag aus der Datenbank-Tabelle löschen:</p>



<pre class="wp-block-code"><code>&lt;?php

namespace App\Http\Controllers;

use App\Models\User;
use Illuminate\Http\Request;
use App\Models\Website;

class WebsitesController extends Controller
{
    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        // destroy method returns true or false
        $websiteSuccessfullyDestroyed = Website::destroy($id);

        if($websiteSuccessfullyDestroyed) {
                return redirect()->route('websites.index')->with('success', 'Website successfully deleted!');
        } else {
                return redirect()->route('websites.index')->with('error', 'Website could not be deleted!');
        }
    }
}</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Laravel TodoApp &#8211; Todo ListItem als erledigt markieren</title>
		<link>https://arasan.de/laravel-todoapp-todo-listitem-als-erledigt-markieren/</link>
		
		<dc:creator><![CDATA[«Æ»]]></dc:creator>
		<pubDate>Fri, 09 Sep 2022 14:39:32 +0000</pubDate>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Blade Templates]]></category>
		<category><![CDATA[Form]]></category>
		<category><![CDATA[Laravel]]></category>
		<category><![CDATA[Model]]></category>
		<category><![CDATA[Tabelle]]></category>
		<category><![CDATA[TodoApp]]></category>
		<guid isPermaLink="false">https://arasan.de/?p=405</guid>

					<description><![CDATA[Nun können wir uns daran machen, unsere neu angelegten Todos als erledigt zu markieren.Dazu brauchen wir pro ListItem einen Button, der das jeweilige als erledigt markiert: Erledigte Todos haben vor dem Eintrag ein &#8222;✓&#8220;, unerledigte werden mit &#8222;o&#8220; dargestellt.Das ganze ist in dem Template der root-Route (&#8222;Welcome.blade.php&#8220;) definiert: Hier haben wir eine if/else Bedingung und&#8230;]]></description>
										<content:encoded><![CDATA[<ol style="margin: 20px"><li><a href="https://arasan.de/laravel-projekt-mit-git-github-erstellen/">Laravel TodoApp &#8211; Projekt mit Git + Github erstellen</a></li><li><a href="https://arasan.de/laravel-view-blade-template-in-atom-editor-bearbeiten/">Laravel TodoApp &#8211; View (Blade Template) in Atom Editor bearbeiten:</a></li><li><a href="https://arasan.de/laravel-mysql-datenbank-verbindung-konfigurieren/">Laravel TodoApp &#8211; MySQL Datenbank-Verbindung konfigurieren</a></li><li><a href="https://arasan.de/laravel-todoapp-model-migration-erstellen/">Laravel TodoApp &#8211; Model + Migration erstellen</a></li><li><a href="https://arasan.de/laravel-todoapp-listitem-form-route-controller-erstellen/">Laravel TodoApp &#8211; ListItem Form + Route + Controller erstellen</a></li><li><a href="https://arasan.de/laravel-todoapp-formulardaten-in-logdatei-ausgeben/">Laravel TodoApp &#8211; Formulardaten in Logdatei ausgeben</a></li><li><a href="https://arasan.de/laravel-todoapp-formulardaten-in-tabelle-speichern/">Laravel TodoApp &#8211; Formulardaten in Tabelle speichern</a></li><li><a href="https://arasan.de/laravel-todoapp-listitems-aus-tabelle-ausgeben/">Laravel TodoApp &#8211; ListItems aus Tabelle ausgeben</a></li><li>Laravel TodoApp &#8211; Todo ListItem als erledigt markieren</li><li><a href="https://arasan.de/laravel-todoapp-layout-erstellen/">Laravel TodoApp &#8211; Layout erstellen</a></li><li><a href="https://arasan.de/laravel-todoapp-bootstrap-hinzufuegen/">Laravel TodoApp &#8211; Bootstrap hinzufügen</a></li><li><a href="https://arasan.de/laravel-todoapp-welcome-blade-template-umbenennen-in-todos/">Laravel TodoApp &#8211; Welcome Blade Template umbenennen in Todos</a></li><li><a href="https://arasan.de/laravel-todoapp-todo-nur-eintragen-wenn-user-angemeldet/">Laravel TodoApp &#8211; Todo nur eintragen wenn User angemeldet</a></li><li><a href="https://arasan.de/laravel-todoapp-nur-eigene-todos-anzeigen-und-bearbeiten/">Laravel TodoApp &#8211; Nur eigene Todos anzeigen und bearbeiten</a></li></ol>



<p class="wp-block-paragraph">Nun können wir uns daran machen, unsere neu angelegten Todos als erledigt zu markieren.<br>Dazu brauchen wir pro ListItem einen Button, der das jeweilige als erledigt markiert:</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="2228" height="998" src="https://arasan.de/wp-content/uploads/2022/09/laravel-todoapp-ausgabe-von-listitems-mit-complete-button-browser.png" alt="" class="wp-image-406"/></figure>



<p class="wp-block-paragraph">Erledigte Todos haben vor dem Eintrag ein &#8222;✓&#8220;, unerledigte werden mit &#8222;o&#8220; dargestellt.<br>Das ganze ist in dem Template der root-Route (&#8222;Welcome.blade.php&#8220;) definiert:</p>



<figure class="wp-block-image size-full"><img decoding="async" width="2512" height="1672" src="https://arasan.de/wp-content/uploads/2022/09/laravel-todoapp-ausgabe-von-listitems-mit-complete-button-in-welcome-view.png" alt="" class="wp-image-407"/></figure>



<p class="wp-block-paragraph">Hier haben wir eine if/else Bedingung und ein Formular mit Submit-Button pro ListItem.<br>Dazu wird das Formular bei Klick auf den &#8222;Complete&#8220;-Button an eine neue Route (mit einem Parameter $id) geschickt.<br>Der Parameter ist notwendig, damit wir das richtige ListItem als erledigt markieren.<br>Nun folgt die Erstellung der Route in der Datei web.php:</p>



<figure class="wp-block-image size-full"><img decoding="async" width="2506" height="1670" src="https://arasan.de/wp-content/uploads/2022/09/laravel-todoapp-form-listitem-complete-route-erstellen.png" alt="" class="wp-image-408"/></figure>



<p class="wp-block-paragraph">In der Route gibt es eine Neuerung, es wird ein Parameter &#8222;$id&#8220; verwendet &#8211; als gültiger Parameter ist eine Zahl definiert (id ist eine Zahl).<br>Außerdem haben wir die Route benannt, damit wir einfacher darauf zugreifen können. </p>



<p class="wp-block-paragraph">Im TodoListController ergänzen wir die Methode &#8222;markItemAsComplete&#8220;, die diesen Anwendungsfall behandelt. </p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2500" height="1672" src="https://arasan.de/wp-content/uploads/2022/09/laravel-todoapp-form-listitem-complete-methode-in-todolistcontroller-erstellen.png" alt="" class="wp-image-409"/></figure>



<p class="wp-block-paragraph">Als weitere Optimierung können wir den &#8222;Complete&#8220;-Button nur dann anzeigen, wenn der Todo Eintrag noch nicht abgeschlossen ist:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2514" height="1666" src="https://arasan.de/wp-content/uploads/2022/09/laravel-todoapp-ausgabe-von-listitems-mit-complete-button-in-welcome-view-nur-wenn-nicht-complete.png" alt="" class="wp-image-410"/></figure>



<p class="wp-block-paragraph">Zu guter Letzt können wir die Farben anpassen:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2514" height="1668" src="https://arasan.de/wp-content/uploads/2022/09/laravel-todoapp-ausgabe-von-listitems-mit-complete-button-angepasste-farben-in-welcome-view.png" alt="" class="wp-image-411"/></figure>



<p class="wp-block-paragraph">Unser Ergebnis kann sich sehen lassen:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2214" height="960" src="https://arasan.de/wp-content/uploads/2022/09/laravel-todoapp-ausgabe-von-listitems-mit-complete-button-angepasste-farben-browser.png" alt="" class="wp-image-412"/></figure>



<p class="wp-block-paragraph">Nun checken wir die Änderungen ein und aktualisieren unser Github Repository mit dem folgenden Befehl:</p>



<pre class="wp-block-code"><code>git push origin master</code></pre>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1824" height="556" src="https://arasan.de/wp-content/uploads/2022/09/laravel-todoapp-git-push-origin-master.png" alt="" class="wp-image-422"/></figure>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Laravel TodoApp &#8211; Formulardaten in Tabelle speichern</title>
		<link>https://arasan.de/laravel-todoapp-formulardaten-in-tabelle-speichern/</link>
		
		<dc:creator><![CDATA[«Æ»]]></dc:creator>
		<pubDate>Fri, 09 Sep 2022 07:49:58 +0000</pubDate>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Laravel]]></category>
		<category><![CDATA[Model]]></category>
		<category><![CDATA[Tabelle]]></category>
		<category><![CDATA[TablePlus]]></category>
		<category><![CDATA[TodoApp]]></category>
		<guid isPermaLink="false">https://arasan.de/?p=383</guid>

					<description><![CDATA[Jetzt können wir die eingegebenen Formulardaten, die per POST Request an unseren TodoListController übertragen werden, in der Tabelle &#8222;list_items&#8220; speichern. Dazu erweitern wir unseren Quelltext wie folgt: Wir prüfen vor dem Speichern der Todo-Items, ob überhaupt Formulardaten ausgefüllt wurden.Nun geben wir im Formular ein neues Todo-Item ein: Nach einem Klick auf Speichern schauen wir uns&#8230;]]></description>
										<content:encoded><![CDATA[<ol style="margin: 20px"><li><a href="https://arasan.de/laravel-projekt-mit-git-github-erstellen/">Laravel TodoApp &#8211; Projekt mit Git + Github erstellen</a></li><li><a href="https://arasan.de/laravel-view-blade-template-in-atom-editor-bearbeiten/">Laravel TodoApp &#8211; View (Blade Template) in Atom Editor bearbeiten:</a></li><li><a href="https://arasan.de/laravel-mysql-datenbank-verbindung-konfigurieren/">Laravel TodoApp &#8211; MySQL Datenbank-Verbindung konfigurieren</a></li><li><a href="https://arasan.de/laravel-todoapp-model-migration-erstellen/">Laravel TodoApp &#8211; Model + Migration erstellen</a></li><li><a href="https://arasan.de/laravel-todoapp-listitem-form-route-controller-erstellen/">Laravel TodoApp &#8211; ListItem Form + Route + Controller erstellen</a></li><li><a href="https://arasan.de/laravel-todoapp-formulardaten-in-logdatei-ausgeben/">Laravel TodoApp &#8211; Formulardaten in Logdatei ausgeben</a></li><li>Laravel TodoApp &#8211; Formulardaten in Tabelle speichern</li><li><a href="https://arasan.de/laravel-todoapp-listitems-aus-tabelle-ausgeben/">Laravel TodoApp &#8211; ListItems aus Tabelle ausgeben</a></li><li><a href="https://arasan.de/laravel-todoapp-todo-listitem-als-erledigt-markieren/">Laravel TodoApp &#8211; Todo ListItem als erledigt markieren</a></li><li><a href="https://arasan.de/laravel-todoapp-layout-erstellen/">Laravel TodoApp &#8211; Layout erstellen</a></li><li><a href="https://arasan.de/laravel-todoapp-bootstrap-hinzufuegen/">Laravel TodoApp &#8211; Bootstrap hinzufügen</a></li><li><a href="https://arasan.de/laravel-todoapp-welcome-blade-template-umbenennen-in-todos/">Laravel TodoApp &#8211; Welcome Blade Template umbenennen in Todos</a></li><li><a href="https://arasan.de/laravel-todoapp-todo-nur-eintragen-wenn-user-angemeldet/">Laravel TodoApp &#8211; Todo nur eintragen wenn User angemeldet</a></li><li><a href="https://arasan.de/laravel-todoapp-nur-eigene-todos-anzeigen-und-bearbeiten/">Laravel TodoApp &#8211; Nur eigene Todos anzeigen und bearbeiten</a></li></ol>



<p class="wp-block-paragraph">Jetzt können wir die eingegebenen Formulardaten, die per POST Request an unseren TodoListController übertragen werden, in der Tabelle &#8222;list_items&#8220; speichern. Dazu erweitern wir unseren Quelltext wie folgt:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="3000" height="1672" src="https://arasan.de/wp-content/uploads/2022/09/laravel-todoapp-form-neues-list-item-request-mit-model-in-tabelle-list_items-speichern.png" alt="" class="wp-image-384"/></figure>



<p class="wp-block-paragraph">Wir prüfen vor dem Speichern der Todo-Items, ob überhaupt Formulardaten ausgefüllt wurden.<br>Nun geben wir im Formular ein neues Todo-Item ein:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2228" height="518" src="https://arasan.de/wp-content/uploads/2022/09/laravel-todoapp-form-neues-list-item-request-ueber-formular-browser.png" alt="" class="wp-image-385"/></figure>



<p class="wp-block-paragraph">Nach einem Klick auf Speichern schauen wir uns die Tabelle &#8222;list_items&#8220; in TablePlus an und sehen unseren neuen Eintrag:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2042" height="608" src="https://arasan.de/wp-content/uploads/2022/09/laravel-todoapp-form-neues-list-item-in-tabelle-list_items-ansehen-tableplus.png" alt="" class="wp-image-388"/></figure>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Laravel TodoApp &#8211; Model + Migration erstellen</title>
		<link>https://arasan.de/laravel-todoapp-model-migration-erstellen/</link>
		
		<dc:creator><![CDATA[«Æ»]]></dc:creator>
		<pubDate>Thu, 08 Sep 2022 15:21:02 +0000</pubDate>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Laravel]]></category>
		<category><![CDATA[Migration]]></category>
		<category><![CDATA[Model]]></category>
		<category><![CDATA[TodoApp]]></category>
		<guid isPermaLink="false">https://arasan.de/?p=340</guid>

					<description><![CDATA[Nach Einrichtung der MySQL Datenbank-Verbindung zum MySQL Server können wir ein Model und die zugehörige Migration für die Tabelle erstellen. Wenn das Model und die Migration erstellt sind, können wir die Migration laufen lassen, damit die Tabellen in der MyQL Datenbank erstellt werden: Die Migrations sind erfolgreich durchgelaufen &#8211; wir können die erstellten Tabellen z.B.&#8230;]]></description>
										<content:encoded><![CDATA[<ol style="margin: 20px"><li><a href="https://arasan.de/laravel-projekt-mit-git-github-erstellen/">Laravel TodoApp &#8211; Projekt mit Git + Github erstellen</a></li><li><a href="https://arasan.de/laravel-view-blade-template-in-atom-editor-bearbeiten/">Laravel TodoApp &#8211; View (Blade Template) in Atom Editor bearbeiten:</a></li><li><a href="https://arasan.de/laravel-mysql-datenbank-verbindung-konfigurieren/">Laravel TodoApp &#8211; MySQL Datenbank-Verbindung konfigurieren</a></li><li>Laravel TodoApp &#8211; Model + Migration erstellen</li><li><a href="https://arasan.de/laravel-todoapp-listitem-form-route-controller-erstellen/">Laravel TodoApp &#8211; ListItem Form + Route + Controller erstellen</a></li><li><a href="https://arasan.de/laravel-todoapp-formulardaten-in-logdatei-ausgeben/">Laravel TodoApp &#8211; Formulardaten in Logdatei ausgeben</a></li><li><a href="https://arasan.de/laravel-todoapp-formulardaten-in-tabelle-speichern/">Laravel TodoApp &#8211; Formulardaten in Tabelle speichern</a></li><li><a href="https://arasan.de/laravel-todoapp-listitems-aus-tabelle-ausgeben/">Laravel TodoApp &#8211; ListItems aus Tabelle ausgeben</a></li><li><a href="https://arasan.de/laravel-todoapp-todo-listitem-als-erledigt-markieren/">Laravel TodoApp &#8211; Todo ListItem als erledigt markieren</a></li><li><a href="https://arasan.de/laravel-todoapp-layout-erstellen/">Laravel TodoApp &#8211; Layout erstellen</a></li><li><a href="https://arasan.de/laravel-todoapp-bootstrap-hinzufuegen/">Laravel TodoApp &#8211; Bootstrap hinzufügen</a></li><li><a href="https://arasan.de/laravel-todoapp-welcome-blade-template-umbenennen-in-todos/">Laravel TodoApp &#8211; Welcome Blade Template umbenennen in Todos</a></li><li><a href="https://arasan.de/laravel-todoapp-todo-nur-eintragen-wenn-user-angemeldet/">Laravel TodoApp &#8211; Todo nur eintragen wenn User angemeldet</a></li><li><a href="https://arasan.de/laravel-todoapp-nur-eigene-todos-anzeigen-und-bearbeiten/">Laravel TodoApp &#8211; Nur eigene Todos anzeigen und bearbeiten</a></li></ol>



<p class="wp-block-paragraph">Nach Einrichtung der <a href="https://arasan.de/laravel-mysql-datenbank-verbindung-konfigurieren/" data-type="post" data-id="335">MySQL Datenbank-Verbindung zum MySQL Server</a> können wir ein Model und die zugehörige Migration für die Tabelle erstellen.</p>



<pre class="wp-block-code"><code>php artisan make:model ListItem -m</code></pre>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1832" height="1276" src="https://arasan.de/wp-content/uploads/2022/09/laravel-todoapp-db-model-migration-erstellen.png" alt="" class="wp-image-342"/></figure>



<p class="wp-block-paragraph">Wenn das Model und die Migration erstellt sind, können wir die Migration laufen lassen, damit die Tabellen in der MyQL Datenbank erstellt werden:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1812" height="1250" src="https://arasan.de/wp-content/uploads/2022/09/laravel-todoapp-migrate-1.png" alt="" class="wp-image-344"/></figure>



<p class="wp-block-paragraph">Die Migrations sind erfolgreich durchgelaufen &#8211; wir können die erstellten Tabellen z.B. in <a href="https://www.tableplus.com">TablePlus</a> anschauen:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1976" height="1308" src="https://arasan.de/wp-content/uploads/2022/09/laravel-todoapp-erstellte-mysql-tabellen-in-tableplus-anschauen.png" alt="" class="wp-image-349"/></figure>



<p class="wp-block-paragraph">Wir erstellen eine weitere Migration und führen sie aus, um neue Spalten zur ListItem Tabelle hinzuzufügen:</p>



<pre class="wp-block-code"><code>php artisan make:migration list_item_name_is_complete</code></pre>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1818" height="162" src="https://arasan.de/wp-content/uploads/2022/09/laravel-todoapp-migration-erstellen-spalte-name-is_complete.png" alt="" class="wp-image-352"/></figure>



<pre class="wp-block-code"><code>php artisan migrate</code></pre>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1826" height="378" src="https://arasan.de/wp-content/uploads/2022/09/laravel-todoapp-migration-ausfuehren-spalte-name-is_complete.png" alt="" class="wp-image-353"/></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1980" height="550" src="https://arasan.de/wp-content/uploads/2022/09/laravel-todoapp-tabelle-list_items-in-tableplus-ansehen.png" alt="" class="wp-image-354"/></figure>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
