Laravel 10 CRUD (Create, Read, Update and Delete) - Tutorial101
Laravel 10 CRUD (Create, Read, Update and Delete) - Tutorial101
tutorial101 is the one place for high quality web development, Web Design and
software development tutorials and Resources programming. Learn cutting edge
techniques in web development, design and software development, download
s o u r c e c o m p o n e n t s a n d p a r t i c i p a t e i n t h e c o m m u n i t y.
ARTICLE
Search
HOME
DB_HOST=127.0.0.1
Codeigniter (32)
DB_PORT=3306
DB_DATABASE=laraveldb
Electron JS (1)
DB_USERNAME=root
DB_PASSWORD=
Github (1)
Create Controller ProductController
php artisan make:controller ProductController --resource
Java (2)
C:\xampp\htdocs\laravel\laravel10project>php artisan make:controller ProductController --resource
app\Http\Controllers\ProductController.php
Java-Swing (6)
1 //app\Http\Controllers\ProductController.php ?
2 <?php Jii Framework (1)
3
4 namespace App\Http\Controllers;
5 Laravel (112)
6 use Illuminate\Http\Request;
7 use App\Models\Product;
8 Magento (2)
9 class ProductController extends Controller
10 {
11 /** mongoDB (11)
12 * Display a listing of the resource.
13 */
14 public function index() Nette Framework (1)
15 {
16 $product = Product::orderBy('created_at', 'DESC')->get();
Next-JS (27)
17
18 return view('product.index', compact('product'));
19 } Node.js (3)
20
21 /**
22 * Show the form for creating a new resource. NodeJS-ExpressJS (17)
23 */
24 public function create()
25 { PostgreSQL (50)
26 return view('product.create');
27 }
28
29 /** python (57)
30 * Store a newly created resource in storage.
31 */
32 public function store(Request $request) python Eel (6)
33 {
34 Product::create($request->all());
35 Python-Alexa (2)
36 return redirect()->route('product.index')->with('success', 'Product added succe
37 } Python-AWS-Lambda (1)
38
39 /**
40 * Display the specified resource. Python-Django (76)
41 */
42 public function show(string $id)
43 { Python-FastAPI (16)
44 $product = Product::findOrFail($id);
45
46 return view('product.show', compact('product')); Python-Flask (192)
47 }
48
49 /** Python-Tkinter (5)
50 * Show the form for editing the specified resource.
51 */
52 public function edit(string $id) python-wxPython (41)
53 {
54 $product = Product::findOrFail($id); React-Native (2)
55
56 return view('product.edit', compact('product'));
57 } ReactJS (101)
58
59 /**
60 * Update the specified resource in storage. SwiftUI-iOS-Xcode (170)
61 */
62 public function update(Request $request, string $id)
63 { Tips-and-Tricks (18)
64 $product = Product::findOrFail($id);
65
66 $product->update($request->all()); Virtualenv (1)
67
68 return redirect()->route('product.index')->with('success', 'product updated suc
69 } Vue CLI (5)
70
71 /** VueJS (26)
72 * Remove the specified resource from storage.
73 */
74 public function destroy(string $id) web-development (25)
75 {
76 $product = Product::findOrFail($id);
77 web-development (ajax) (61)
78 $product->delete();
79
80 return redirect()->route('product.index')->with('success', 'product deleted suc web-development (CSS) (91)
81 }
resources/views/layouts/navbar.blade.php
Laravel Multi User Authentication
1 //resources/views/layouts/navbar.blade.php ? Laravel Multi User Authentication
2 <nav class="navbar navbar-expand-lg bg-body-tertiary">
3 <div class="container"> Download Laravel App composer
4 <a class="navbar-brand" href="#">Navbar</a> create-project --prefer-dist
5 <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs laravel/laravel my-app
6 <span class="navbar-toggler-icon"></span>
7 </button> C:\xampp\htdocs\laravel...
8 <div class="collapse navbar-collapse" id="navbarSupportedContent">
9 <ul class="navbar-nav me-auto mb-2 mb-lg-0"> Laravel 10 How To Integrate Stripe
10 <li class="nav-item">
11 <a class="nav-link" href="/">Home</a> Payment Gateway
12 </li> Laravel 10 How To Integrate Stripe
13 <li class="nav-item">
14 <a class="nav-link" href="{{ route('product.index') }}">Product</a> Payment Gateway Download Laravel
15 </li> App composer create-project --prefer-
16 </ul> dist laravel/laravel my-app C:\xam...
17 </div>
18 </div>
19 </nav> Laravel 11 CRUD with upload image
Laravel 11 CRUD with upload image
resources/views/product/create.blade.php Laravel 11 CRUD with upload image
Download Laravel App
1 //resources/views/product/create.blade.php ? https://laravel.com/docs/11.x/install
2 @extends('layouts.app')
3 ation ...
4 @section('body')
5 <h1 class="mb-0">Add Book</h1> Python Flask Upload and display
6 <hr />
7 <form action="{{ route('product.store') }}" method="POST"> image
8 @csrf Python Flask Upload and display
9 <div class="row mb-3">
10 <div class="col"> image app.py #app.py from flask
11 <input type="text" name="title" class="form-control" placeholder="Title import Flask, flash, request, redirect,
12 </div> url_for, render_template import u...
13 <div class="col">
14 <input type="text" name="price" class="form-control" placeholder="Price
15 </div>
16 </div>
17 <div class="row mb-3">
18 <div class="col">
19 <input type="text" name="product_code" class="form-control" placeholder
20 </div>
21 <div class="col">
22 <textarea class="form-control" name="description" placeholder="Descript
23 </div>
24 </div>
25 <div class="row">
26 <div class="d-grid">
27 <button class="btn btn-primary">Submit</button>
28 </div>
29 </div>
30 </form>
resources/views/product/edit.blade.php
1 //resources/views/product/edit.blade.php ?
2 @extends('layouts.app')
3
4 @section('body')
5 <h1 class="mb-0">Edit Product</h1>
6 <hr />
7 <form action="{{ route('product.update', $product->id) }}" method="POST">
8 @csrf
9 @method('PUT')
10 <div class="row">
11 <div class="col mb-3">
12 <label class="form-label">Title</label>
13 <input type="text" name="title" class="form-control" placeholder="Title
14 </div>
15 <div class="col mb-3">
16 <label class="form-label">Price</label>
17 <input type="text" name="price" class="form-control" placeholder="Price
18 </div>
19 </div>
20 <div class="row">
21 <div class="col mb-3">
22 <label class="form-label">Product Code</label>
23 <input type="text" name="product_code" class="form-control" placeholder
24 </div>
25 <div class="col mb-3">
26 <label class="form-label">Description</label>
27 <textarea class="form-control" name="description" placeholder="Descript
28 </div>
29 </div>
30 <div class="row">
31 <div class="d-grid">
32 <button class="btn btn-warning">Update</button>
33 </div>
34 </div>
35 </form>
36 @endsection
resources/views/product/index.blade.php
1 //resources/views/product/index.blade.php ?
2 @extends('layouts.app')
3
4 @section('body')
5 <div class="d-flex align-items-center justify-content-between">
6 <h1 class="mb-0">List Product</h1>
7 <a href="{{ route('product.create') }}" class="btn btn-primary">Add Product</a>
8 </div>
9 <hr />
10 @if(Session::has('success'))
11 <div class="alert alert-success" role="alert">
12 {{ Session::get('success') }}
13 </div>
14 @endif
15 <table class="table table-hover">
16 <thead class="table-primary">
17 <tr>
18 <th>#</th>
19 <th>Title</th>
20 <th>Price</th>
21 <th>Product Code</th>
22 <th>Description</th>
23 <th>Action</th>
24 </tr>
25 </thead>
26 <tbody>
27 @if($product->count() > 0)
28 @foreach($product as $rs)
29 <tr>
30 <td class="align-middle">{{ $loop->iteration }}</td>
31 <td class="align-middle">{{ $rs->title }}</td>
32 <td class="align-middle">{{ $rs->price }}</td>
33 <td class="align-middle">{{ $rs->product_code }}</td>
34 <td class="align-middle">{{ $rs->description }}</td>
35 <td class="align-middle">
36 <div class="btn-group" role="group" aria-label="Basic examp
37 <a href="{{ route('product.show', $rs->id) }}" type="bu
38 <a href="{{ route('product.edit', $rs->id)}}" type="but
39 <form action="{{ route('product.destroy', $rs->id) }}"
40 @csrf
41 @method('DELETE')
42 <button class="btn btn-danger m-0">Delete</button>
43 </form>
44 </div>
45 </td>
46 </tr>
47 @endforeach
48 @else
49 <tr>
50 <td class="text-center" colspan="5">Product not found</td>
51 </tr>
52 @endif
53 </tbody>
54 </table>
55 @endsection
resources/views/product/show.blade.php
1 //resources/views/product/show.blade.php ?
2 @extends('layouts.app')
3
4 @section('body')
5 <h1 class="mb-0">Detail Product</h1>
6 <hr />
7 <div class="row">
8 <div class="col mb-3">
9 <label class="form-label">Title</label>
10 <input type="text" name="title" class="form-control" placeholder="Title" va
11 </div>
12 <div class="col mb-3">
13 <label class="form-label">Price</label>
14 <input type="text" name="price" class="form-control" placeholder="Price" va
15 </div>
16 </div>
17 <div class="row">
18 <div class="col mb-3">
19 <label class="form-label">product_code</label>
20 <input type="text" name="product_code" class="form-control" placeholder="Pr
21 </div>
22 <div class="col mb-3">
23 <label class="form-label">Description</label>
24 <textarea class="form-control" name="description" placeholder="Descriptoin
25 </div>
26 </div>
27 <div class="row">
28 <div class="col mb-3">
29 <label class="form-label">Created At</label>
30 <input type="text" name="created_at" class="form-control" placeholder="Crea
31 </div>
32 <div class="col mb-3">
33 <label class="form-label">Updated At</label>
34 <input type="text" name="updated_at" class="form-control" placeholder="Upda
35 </div>
36 </div>
37 @endsection
1 //routes/web.php ?
2 <?php
3
4 use Illuminate\Support\Facades\Route;
5 use App\Http\Controllers\ProductController;
6
7
8 Route::get('/', function () {
9 return view('welcome');
10 });
11
12 Route::resource('/product', ProductController::class);
tutorial101.blogspot.com is © 2010-2021