<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: raviyatechnical</title>
    <description>The latest articles on DEV Community by raviyatechnical (@raviyatechnical).</description>
    <link>https://dev.to/raviyatechnical</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F408564%2Fedb98acb-bc75-45da-9ed5-c88262a203a2.png</url>
      <title>DEV Community: raviyatechnical</title>
      <link>https://dev.to/raviyatechnical</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/raviyatechnical"/>
    <language>en</language>
    <item>
      <title>Laravel CRUD | Laravel MongoDB CRUD Tutorial Example</title>
      <dc:creator>raviyatechnical</dc:creator>
      <pubDate>Sun, 01 Oct 2023 13:43:37 +0000</pubDate>
      <link>https://dev.to/raviyatechnical/laravel-crud-laravel-mongodb-crud-tutorial-example-5hld</link>
      <guid>https://dev.to/raviyatechnical/laravel-crud-laravel-mongodb-crud-tutorial-example-5hld</guid>
      <description>&lt;p&gt;Step 1 : create db of ‘mongodb’&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mongo
&amp;gt; use mongodb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 2: Setup Env variable (.env) &amp;amp; Config File&lt;/p&gt;

&lt;p&gt;.env&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MONGO_DB_HOST=127.0.0.1
MONGO_DB_PORT=27017
MONGO_DB_DATABASE=mongodb
MONGO_DB_USERNAME=
MONGO_DB_PASSWORD=
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;config/database.php&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php
return [
    ....
    'connections' =&amp;gt; [
        ......
        'mongodb' =&amp;gt; [
            'driver'   =&amp;gt; 'mongodb',
            'host'     =&amp;gt; env('MONGO_DB_HOST', 'localhost'),
            'port'     =&amp;gt; env('MONGO_DB_PORT', 27017),
            'database' =&amp;gt; env('MONGO_DB_DATABASE'),
            'username' =&amp;gt; env('MONGO_DB_USERNAME'),
            'password' =&amp;gt; env('MONGO_DB_PASSWORD'),
            'options'  =&amp;gt; []
        ],
    ]
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 3: Install Mongo Db Package&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer require mongodb/laravel-mongodb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If not working Try This method&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer require mongodb/laravel-mongodb --ignore-platform-req=ext-mongodb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 4: Create A Model&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan make:model Article -m
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;app/Models/Article.php&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use MongoDB\Laravel\Eloquent\Model;

class Article extends Model
{
    use HasFactory;
    protected $connection = 'mongodb';
    protected $collection = 'articles';
    protected $fillable = [
        'name', 'detail'
    ];
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 5: Create A Controller&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan make:controller ArticleController
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;app/Http/Controllers/ArticleController.php&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Article;

class ArticleController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $articles = Article::all();
        return view('articles.index', compact('articles'))
            -&amp;gt;with('i', (request()-&amp;gt;input('page', 1) - 1) * 5);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('articles.create');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        request()-&amp;gt;validate([
            'name' =&amp;gt; 'required',
            'detail' =&amp;gt; 'required',
        ]);
        Article::create($request-&amp;gt;all());
        return redirect()-&amp;gt;route('articles.index')
            -&amp;gt;with('success', 'Article created successfully.');
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Article  $article
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        $article = Article::find($id);
        return view('articles.show', compact('article'));
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Article  $article
     * @return \Illuminate\Http\Response
     */

    public function edit($id)
    {
        $article = Article::find($id);
        return view('articles.edit', compact('article'));
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Article  $article
     * @return \Illuminate\Http\Response
     */

    public function update(Request $request, $id)
    {
        request()-&amp;gt;validate([
            'name' =&amp;gt; 'required',
            'detail' =&amp;gt; 'required',
        ]);
        $article = Article::find($id);
        $article-&amp;gt;update($request-&amp;gt;all());
        return redirect()-&amp;gt;route('articles.index')
            -&amp;gt;with('success', 'Article updated successfully');
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Article  $article
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        $article = Article::find($id);
        $article-&amp;gt;delete();
        return redirect()-&amp;gt;route('articles.index')
            -&amp;gt;with('success', 'Article deleted successfully');
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 6: Create Blade Files&lt;br&gt;
1) app.blade.php (If Not Exits)&lt;/p&gt;

&lt;p&gt;2) index.blade.php&lt;/p&gt;

&lt;p&gt;3) show.blade.php&lt;/p&gt;

&lt;p&gt;4) form.blade.php&lt;/p&gt;

&lt;p&gt;5) create.blade.php&lt;/p&gt;

&lt;p&gt;6) edit.blade.php&lt;/p&gt;

&lt;p&gt;resources/views/layouts/app.blade.php (If not exits)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!doctype html&amp;gt;
&amp;lt;html lang="en"&amp;gt;

&amp;lt;head&amp;gt;
    &amp;lt;!-- Required meta tags --&amp;gt;
    &amp;lt;meta charset="utf-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1"&amp;gt;

    &amp;lt;!-- Bootstrap CSS --&amp;gt;
    &amp;lt;link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"&amp;gt;

    &amp;lt;title&amp;gt;Laravel MongoDB CRUD Application - Raviya Technical&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
    &amp;lt;div class="container"&amp;gt;
        @yield('content')
    &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;resources/views/articles/index.blade.php&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@extends('layouts.app')
@section('content')
    &amp;lt;div class="row"&amp;gt;
        &amp;lt;div class="col-lg-12 margin-tb"&amp;gt;
            &amp;lt;div class="pull-left"&amp;gt;
                &amp;lt;h2&amp;gt;Articles&amp;lt;/h2&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="pull-right"&amp;gt;
                &amp;lt;a class="btn btn-success" href="{{ route('articles.create') }}"&amp;gt; Create New Article&amp;lt;/a&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;

    @if ($message = Session::get('success'))
        &amp;lt;div class="alert alert-success"&amp;gt;
            &amp;lt;p&amp;gt;{{ $message }}&amp;lt;/p&amp;gt;
        &amp;lt;/div&amp;gt;
    @endif

    &amp;lt;table class="table table-bordered"&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;th&amp;gt;No&amp;lt;/th&amp;gt;
            &amp;lt;th&amp;gt;Name&amp;lt;/th&amp;gt;
            &amp;lt;th&amp;gt;Details&amp;lt;/th&amp;gt;
            &amp;lt;th width="280px"&amp;gt;Action&amp;lt;/th&amp;gt;
        &amp;lt;/tr&amp;gt;
        @foreach ($articles as $article)
            &amp;lt;tr&amp;gt;
                &amp;lt;td&amp;gt;{{ ++$i }}&amp;lt;/td&amp;gt;
                &amp;lt;td&amp;gt;{{ $article-&amp;gt;name }}&amp;lt;/td&amp;gt;
                &amp;lt;td&amp;gt;{{ $article-&amp;gt;detail }}&amp;lt;/td&amp;gt;
                &amp;lt;td&amp;gt;
                    &amp;lt;form action="{{ route('articles.destroy', $article-&amp;gt;id) }}" method="POST"&amp;gt;
                        &amp;lt;a class="btn btn-info" href="{{ route('articles.show', $article-&amp;gt;id) }}"&amp;gt;Show&amp;lt;/a&amp;gt;
                        &amp;lt;a class="btn btn-primary" href="{{ route('articles.edit', $article-&amp;gt;id) }}"&amp;gt;Edit&amp;lt;/a&amp;gt;
                        @csrf
                        @method('DELETE')
                        &amp;lt;button type="submit" class="btn btn-danger"&amp;gt;Delete&amp;lt;/button&amp;gt;
                    &amp;lt;/form&amp;gt;
                &amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt;
        @endforeach
    &amp;lt;/table&amp;gt;
@endsection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;resources/views/articles/show.blade.php&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@extends('layouts.app')
@section('content')
    &amp;lt;div class="row"&amp;gt;
        &amp;lt;div class="col-lg-12 margin-tb"&amp;gt;
            &amp;lt;div class="pull-left"&amp;gt;
                &amp;lt;h2&amp;gt; Show Article&amp;lt;/h2&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="pull-right"&amp;gt;
                &amp;lt;a class="btn btn-primary" href="{{ route('articles.index') }}"&amp;gt; Back&amp;lt;/a&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="row"&amp;gt;
        &amp;lt;div class="col-xs-12 col-sm-12 col-md-12"&amp;gt;
            &amp;lt;div class="form-group"&amp;gt;
                &amp;lt;strong&amp;gt;Name:&amp;lt;/strong&amp;gt;
                {{ $article-&amp;gt;name }}
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div class="col-xs-12 col-sm-12 col-md-12"&amp;gt;
            &amp;lt;div class="form-group"&amp;gt;
                &amp;lt;strong&amp;gt;Details:&amp;lt;/strong&amp;gt;
                {{ $article-&amp;gt;detail }}
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
@endsection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;resources/views/articles/create.blade.php&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@extends('layouts.app')
@section('content')
    &amp;lt;div class="row"&amp;gt;
        &amp;lt;div class="col-lg-12 margin-tb"&amp;gt;
            &amp;lt;div class="pull-left"&amp;gt;
                &amp;lt;h2&amp;gt;Add New Article&amp;lt;/h2&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="pull-right"&amp;gt;
                &amp;lt;a class="btn btn-primary" href="{{ route('articles.index') }}"&amp;gt; Back&amp;lt;/a&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;

    @if ($errors-&amp;gt;any())
        &amp;lt;div class="alert alert-danger"&amp;gt;
            &amp;lt;strong&amp;gt;Whoops!&amp;lt;/strong&amp;gt; There were some problems with your input.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
            &amp;lt;ul&amp;gt;
                @foreach ($errors-&amp;gt;all() as $error)
                    &amp;lt;li&amp;gt;{{ $error }}&amp;lt;/li&amp;gt;
                @endforeach
            &amp;lt;/ul&amp;gt;
        &amp;lt;/div&amp;gt;
    @endif

    &amp;lt;form action="{{ route('articles.store') }}" method="POST"&amp;gt;
        @csrf
        &amp;lt;div class="row"&amp;gt;
            &amp;lt;div class="col-xs-12 col-sm-12 col-md-12"&amp;gt;
                &amp;lt;div class="form-group"&amp;gt;
                    &amp;lt;strong&amp;gt;Name:&amp;lt;/strong&amp;gt;
                    &amp;lt;input type="text" name="name" class="form-control" placeholder="Name"&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="col-xs-12 col-sm-12 col-md-12"&amp;gt;
                &amp;lt;div class="form-group"&amp;gt;
                    &amp;lt;strong&amp;gt;Detail:&amp;lt;/strong&amp;gt;
                    &amp;lt;textarea class="form-control" style="height:150px" name="detail" placeholder="Detail"&amp;gt;&amp;lt;/textarea&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="col-xs-12 col-sm-12 col-md-12 text-center"&amp;gt;
                &amp;lt;button type="submit" class="btn btn-primary"&amp;gt;Submit&amp;lt;/button&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/form&amp;gt;
@endsectiontest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;resources/views/articles/edit.blade.php&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@extends('layouts.app')
@section('content')
    &amp;lt;div class="row"&amp;gt;
        &amp;lt;div class="col-lg-12 margin-tb"&amp;gt;
            &amp;lt;div class="pull-left"&amp;gt;
                &amp;lt;h2&amp;gt;Edit Article&amp;lt;/h2&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="pull-right"&amp;gt;
                &amp;lt;a class="btn btn-primary" href="{{ route('articles.index') }}"&amp;gt; Back&amp;lt;/a&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
    @if ($errors-&amp;gt;any())
        &amp;lt;div class="alert alert-danger"&amp;gt;
            &amp;lt;strong&amp;gt;Whoops!&amp;lt;/strong&amp;gt; There were some problems with your input.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
            &amp;lt;ul&amp;gt;
                @foreach ($errors-&amp;gt;all() as $error)
                    &amp;lt;li&amp;gt;{{ $error }}&amp;lt;/li&amp;gt;
                @endforeach
            &amp;lt;/ul&amp;gt;
        &amp;lt;/div&amp;gt;
    @endif

    &amp;lt;form action="{{ route('articles.update', $article-&amp;gt;_id) }}" method="POST"&amp;gt;
        @csrf
        @method('PUT')
        &amp;lt;div class="row"&amp;gt;
            &amp;lt;div class="col-xs-12 col-sm-12 col-md-12"&amp;gt;
                &amp;lt;div class="form-group"&amp;gt;
                    &amp;lt;strong&amp;gt;Name:&amp;lt;/strong&amp;gt;
                    &amp;lt;input type="text" name="name" value="{{ $article-&amp;gt;name }}" class="form-control"
                        placeholder="Name"&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;

            &amp;lt;div class="col-xs-12 col-sm-12 col-md-12"&amp;gt;
                &amp;lt;div class="form-group"&amp;gt;
                    &amp;lt;strong&amp;gt;Detail:&amp;lt;/strong&amp;gt;
                    &amp;lt;textarea class="form-control" style="height:150px" name="detail" placeholder="Detail"&amp;gt;{{ $article-&amp;gt;detail }}&amp;lt;/textarea&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;

            &amp;lt;div class="col-xs-12 col-sm-12 col-md-12 text-center"&amp;gt;
                &amp;lt;button type="submit" class="btn btn-primary"&amp;gt;Submit&amp;lt;/button&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/form&amp;gt;
@endsection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 7: Add Route in web.php&lt;br&gt;
routes/web.php&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;use App\Http\Controllers\ArticleController;

Route::resource('articles',ArticleController::class);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 8: Run Project&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan serve
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="http://127.0.0.1:8000/articles"&gt;http://127.0.0.1:8000/articles&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/sponsors/bhargavraviya"&gt;https://github.com/sponsors/bhargavraviya&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.patreon.com/raviyatechnical"&gt;https://www.patreon.com/raviyatechnical&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Laravel Livewire | How to Build a CRUD Application with Pagination (Tall Stack Example)</title>
      <dc:creator>raviyatechnical</dc:creator>
      <pubDate>Sun, 30 Apr 2023 07:58:06 +0000</pubDate>
      <link>https://dev.to/raviyatechnical/laravel-livewire-how-to-build-a-crud-application-with-pagination-tall-stack-example-1bf3</link>
      <guid>https://dev.to/raviyatechnical/laravel-livewire-how-to-build-a-crud-application-with-pagination-tall-stack-example-1bf3</guid>
      <description>&lt;p&gt;Step 1: Install Laravel&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer create-project laravel/laravel laravel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 2: Create Dummy Records using Tinker Factory&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan tinker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User::factory()-&amp;gt;count(100)-&amp;gt;create()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 3: Install Tall Stack&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/raviyatechnical/laravel-tall-stack-authentication-simplifying-user-management-for-web-applications-4cf7"&gt;https://dev.to/raviyatechnical/laravel-tall-stack-authentication-simplifying-user-management-for-web-applications-4cf7&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Step 4: Create Component&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan make:livewire Users/UserList
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now they created fies on both path:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;app/Http/Livewire/Users/UserList.php &lt;/p&gt;

&lt;p&gt;resources/views/livewire/users/user-list.blade.php&lt;br&gt;
Now both file we will update as bellow for our contact us form.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;app/Http/Livewire/Users/UserList.php&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Http\Livewire\Users;

use Livewire\Component;
use App\Models\User;
use Illuminate\Support\Facades\Hash;
use Livewire\WithPagination;

class UserList extends Component
{
    use WithPagination;

    public $name, $email, $password;
    public $user_id;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    public function render()
    {
        return view('livewire.users.user-list',[
            'users' =&amp;gt; User::paginate(15)
        ]);
    }

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    private function resetInputFields()
    {
        $this-&amp;gt;name = '';
        $this-&amp;gt;email = '';
        $this-&amp;gt;password = '';
    }

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    public function edit($id)
    {
        $user = User::findOrFail($id);
        $this-&amp;gt;user_id = $id;
        if ($user) {
            $this-&amp;gt;name = $user-&amp;gt;name;
            $this-&amp;gt;email = $user-&amp;gt;email;
        }
    }

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    public function cancel()
    {
        $this-&amp;gt;user_id = null;
        $this-&amp;gt;resetInputFields();
    }

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    public function save()
    {
        $validatedData = $this-&amp;gt;validate([
            'name' =&amp;gt; 'required',
            'email' =&amp;gt; 'required|email',
            'password' =&amp;gt; ($this-&amp;gt;user_id) ? 'nullable' : 'required',
            'user_id' =&amp;gt; 'nullable'
        ]);

        if (!empty($validatedData['password'])) {
            $validatedData['password'] = Hash::make($validatedData['password']);
        } else {
            unset($validatedData['password']);
        }
        $userQuery = User::query();
        if (!empty($validatedData['user_id'])) {
            $user = $userQuery-&amp;gt;find($validatedData['user_id']);
            if ($user) {
                $user-&amp;gt;update($validatedData);
            }
        } else {
            $userQuery-&amp;gt;create($validatedData);
        }

        $this-&amp;gt;user_id = null;
        session()-&amp;gt;flash('message', 'User Created Successfully.');
        $this-&amp;gt;resetInputFields();
    }

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    public function delete($id)
    {
        $user = User::find($id);
        if ($user) {
            $user-&amp;gt;delete();
        }
        session()-&amp;gt;flash('message', 'User Deleted Successfully.');
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make Componet&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan make component Forms/Input --view
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;resources/views/components/forms/input.blade.php&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@props(['type' =&amp;gt; 'text', 'label', 'name', 'value', 'placeholder', 'required'])

&amp;lt;div class="mb-6"&amp;gt;
    &amp;lt;label for="{{ $name }}"
        class="block mb-2 text-sm font-medium text-gray-900 dark:text-white"&amp;gt;{{ $label }}&amp;lt;/label&amp;gt;
    &amp;lt;input type="{{ $type }}" wire:model.defer="{{ $name }}" id="{{ $name }}"
        name="{{ $name }}" value="{{ $value }}"
        class="block w-full p-2 text-gray-900 border border-gray-300 rounded-lg bg-gray-50 sm:text-xs focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
        placeholder="{{ $placeholder }}" @if ($required) required @endif&amp;gt;
    @error($name)
        &amp;lt;span class="mt-2 text-sm text-red-600 dark:text-red-500"&amp;gt;{{ $message }}&amp;lt;/span&amp;gt;
    @enderror
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;resources/views/livewire/users/user-list.blade.php&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div&amp;gt;
    @if (session()-&amp;gt;has('message'))
        &amp;lt;div class="alert alert-success"&amp;gt;
            {{ session('message') }}
        &amp;lt;/div&amp;gt;
    @endif

    &amp;lt;form
        class="w-full max-w-sm p-4 mt-4 mb-4 bg-white border border-gray-200 rounded-lg shadow sm:p-6 dark:bg-gray-800 dark:border-gray-700"&amp;gt;
        &amp;lt;input type="hidden" wire:model="user_id"&amp;gt;
        &amp;lt;x-forms.input type="text" label="Name" name="name" value="{{ old('name') }}" placeholder="Enter Name"
            required /&amp;gt;
        &amp;lt;x-forms.input type="email" label="Email" name="email" value="{{ old('email') }}" placeholder="Enter Email"
            required /&amp;gt;
        &amp;lt;x-forms.input type="password" label="Password" name="password" value="{{ old('password') }}"
            placeholder="Enter Password" required /&amp;gt;
        &amp;lt;button wire:click.prevent="save()"
            class="px-3 py-2 text-sm font-medium text-center text-white bg-blue-700 rounded-lg hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"&amp;gt;Save&amp;lt;/button&amp;gt;
        &amp;lt;button wire:click.prevent="cancel()"
            class="px-3 py-2 text-sm font-medium text-center text-white bg-red-700 rounded-lg hover:bg-red-800 focus:ring-4 focus:outline-none focus:ring-red-300 dark:bg-red-600 dark:hover:bg-red-700 dark:focus:ring-red-800"&amp;gt;Cancel&amp;lt;/button&amp;gt;
    &amp;lt;/form&amp;gt;
    &amp;lt;div class="relative overflow-x-auto shadow-md sm:rounded-lg"&amp;gt;
        &amp;lt;table class="w-full text-sm text-left text-gray-500 dark:text-gray-400"&amp;gt;
            &amp;lt;thead class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400"&amp;gt;
                &amp;lt;tr&amp;gt;
                    &amp;lt;th scope="col" class="px-6 py-3"&amp;gt;
                        No.
                    &amp;lt;/th&amp;gt;
                    &amp;lt;th scope="col" class="px-6 py-3"&amp;gt;
                        Name
                    &amp;lt;/th&amp;gt;
                    &amp;lt;th scope="col" class="px-6 py-3"&amp;gt;
                        Email
                    &amp;lt;/th&amp;gt;
                    &amp;lt;th scope="col" class="px-6 py-3"&amp;gt;
                        Action
                    &amp;lt;/th&amp;gt;
                &amp;lt;/tr&amp;gt;
            &amp;lt;/thead&amp;gt;
            &amp;lt;tbody&amp;gt;
                @php
                    $i = (request()-&amp;gt;input('page', 1) - 1) * 15;
                @endphp
                @foreach ($users as $key =&amp;gt; $user)
                    &amp;lt;tr class="bg-white border-b dark:bg-gray-900 dark:border-gray-700"&amp;gt;
                        &amp;lt;th scope="row"
                            class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white"&amp;gt;
                            {{-- {{ $user-&amp;gt;id }} --}}
                            {{ ++$i }}
                        &amp;lt;/th&amp;gt;
                        &amp;lt;td class="px-6 py-4"&amp;gt;
                            {{ $user-&amp;gt;name }}
                        &amp;lt;/td&amp;gt;
                        &amp;lt;td class="px-6 py-4"&amp;gt;
                            {{ $user-&amp;gt;email }}
                        &amp;lt;/td&amp;gt;
                        &amp;lt;td class="px-6 py-4"&amp;gt;
                            &amp;lt;button wire:click="edit({{ $user-&amp;gt;id }})"
                                class="font-medium text-blue-600 dark:text-blue-500 hover:underline"&amp;gt;Edit&amp;lt;/button&amp;gt;
                            &amp;lt;button wire:click="delete({{ $user-&amp;gt;id }})"
                                class="font-medium text-blue-600 dark:text-blue-500 hover:underline"&amp;gt;Delete&amp;lt;/button&amp;gt;
                        &amp;lt;/td&amp;gt;
                    &amp;lt;/tr&amp;gt;
                @endforeach
            &amp;lt;/tbody&amp;gt;
        &amp;lt;/table&amp;gt;
        &amp;lt;div class="p-3"&amp;gt;
            {{ $users-&amp;gt;links() }}
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 5: Create Route&lt;br&gt;
Create controller UserController&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan make:controller UserController
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;app/Http/Controllers/UserController.php&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class UserController extends Controller
{
    public function index()
    {
        return view('users.index');
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;routes/web.php&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Route::get('users', [UserController::class, 'index'])-&amp;gt;name('users.index');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 6: Create View File&lt;br&gt;
&lt;strong&gt;resources/views/users/index.blade.php&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@extends('layouts.app')
@section('content')
    @livewire('users.user-list')
@endsection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run Laravel App:&lt;br&gt;
Now you can run using bellow command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan serve
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open bellow URL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:8000/users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I hope it can help you...&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>tallstack</category>
      <category>livewire</category>
      <category>php</category>
    </item>
    <item>
      <title>Laravel TALL Stack Authentication: Simplifying User Management for Web Applications</title>
      <dc:creator>raviyatechnical</dc:creator>
      <pubDate>Sun, 30 Apr 2023 07:56:47 +0000</pubDate>
      <link>https://dev.to/raviyatechnical/laravel-tall-stack-authentication-simplifying-user-management-for-web-applications-4cf7</link>
      <guid>https://dev.to/raviyatechnical/laravel-tall-stack-authentication-simplifying-user-management-for-web-applications-4cf7</guid>
      <description>&lt;p&gt;To create a CRUD operation in a Laravel TALL stack (Tailwind CSS, Alpine.js, Laravel, and Livewire), you can follow these steps:&lt;/p&gt;

&lt;p&gt;Create a new Laravel project using the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;laravel new myapp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install the TALL stack dependencies by running the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer require livewire/livewire laravel-frontend-presets/tall --dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Generate the scaffolding for the TALL stack using the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan ui tall --auth
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Migrate the database by running the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run Laravel App:&lt;/p&gt;

&lt;p&gt;Now you can run using bellow command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan serve
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open bellow URL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:8000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I hope it can help you…&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>tallstack</category>
      <category>livewire</category>
      <category>php</category>
    </item>
  </channel>
</rss>
