0% found this document useful (0 votes)
95 views6 pages

Laravel 10 CRUD (Create, Read, Update and Delete) - Tutorial101

Uploaded by

Riadh El Fehri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views6 pages

Laravel 10 CRUD (Create, Read, Update and Delete) - Tutorial101

Uploaded by

Riadh El Fehri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

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

Laravel 10 CRUD (Create, Read, Update and Delete)


SEARCH THIS BLOG

Search

HOME

Laravel 10 CRUD (Create, Read, Update and Delete)


C AT E G O R Y
Download Laravel App
Alexa (2)
composer create-project --prefer-dist laravel/laravel my-app
C:\xampp\htdocs\laravel10project>composer create-project laravel/laravel laravel10project Android (3)

Connecting our Database AngularJS (41)

open .env file root directory. Bootstrap (13)

DB_CONNECTION=mysql CakePHP (10)

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 }

Database Migration web-development (htaccess) (6)

web-development (JavaScript) (38)


C:\xampp\htdocs\laravel\laravel10project>php artisan make:model Product -m

web-development (jquery) (224)


database/migrations/create_products_table.php

1 //database/migrations/create_products_table.php ? web-development (photoshop) (1)


2 <?php
3
4 use Illuminate\Database\Migrations\Migration; web-development (PHP-MYSQL) (127)
5 use Illuminate\Database\Schema\Blueprint;
6 use Illuminate\Support\Facades\Schema;
7 web-development (PHP) (78)
8 return new class extends Migration
9 {
10 public function up(): void WordPress (21)
11 {
12 Schema::create('products', function (Blueprint $table) {
13 $table->id();
14 $table->string('title');
15 $table->string('price');
16 $table->string('product_code');
17 $table->text('description'); POPULAR POSTS
18 $table->timestamps();
19 });
20 } Laravel 10 CRUD (Create, Read,
21
Update and Delete) with admin and
22 public function down(): void
23 { Custom Login register
24 Schema::dropIfExists('products');
Laravel 10 CRUD (Create, Read,
25 }
26 }; Update and Delete) with admin and
Custom Login register Download Laravel App
run this migration composer create-project --prefe...
C:\xampp\htdocs\laravel\laravel10project>php artisan migrate
Laravel 10 Login Register with Multi
open app/Product.php and update the below field User Authentication and CRUD
app/Models/Product.php Admin Page
Laravel 10 Login Register with Multi
1 //app/Models/Product.php ?
2 <?php User Authentication and CRUD
3 Admin Page Download Laravel App composer
4 namespace App\Models;
5 create-project --prefer-dist ...
6 use Illuminate\Database\Eloquent\Factories\HasFactory;
7 use Illuminate\Database\Eloquent\Model; Laravel 9 CRUD (Create, Read,
8
9 class Product extends Model Update and Delete)
10 { Laravel 9 CRUD (Create, Read,
11 use HasFactory;
Update and Delete) How to install
12
13 protected $fillable = [ laravel 9
14 'title', https://tutorial101.blogspot.com/2022/02/how-to-
15 'price',
16 'product_code', install-laravel-9...
17 'description'
18 ]; Laravel 10 Custom Login and
19 }
Registration
Create Blade View
Bootstrap 5 https://getbootstrap.com/docs/5.3/getting-started/download/ Laravel 10 Custom Login and
Registration Download Laravel App
create folder layouts and product
composer create-project --prefer-dist
resources/views/layouts/app.blade.php
laravel/laravel my-app C:\xampp\htdocs\...
1 //resources/views/layouts/app.blade.php ?
2 <!doctype html> Laravel 11 Multi Auth using Breeze
3 <html lang="en">
4 <head> with CRUD Admin
5 <meta charset="utf-8"> Laravel 11 Multi Auth using Breeze
6 <meta name="viewport" content="width=device-width, initial-scale=1">
7 <title>Laravel 10 CRUD (Create, Read, Update and Delete)</title> with CRUD Admin Download Laravel
8 <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap App
9 </head> https://laravel.com/docs/11.x/installation
10 <body>
11 @include('layouts.navbar') composer global ...
12
13 <div class="container py-5"> Django Mysql CRUD (Create Read
14 @yield('body')
15 </div> Update Delete) with Datatables
16 Django Mysql CRUD (Create Read
17 <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap
18 </body> Update Delete) with Datatables
19 </html> Register App myapp and Connect to
MySQL Database devproject/settings.py...

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

Define Route routes/web.php

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);

Run C:\xampp\htdocs\laravel\laravel10project>php artisan serve


Starting Laravel development server: http://127.0.0.1:8000

Laravel 10 CRUD (Create, Read, Update and Delete)


Posted by ednalan at 8:45 PM . Under Laravel .

Newer Post Home Older Post


R E L AT E D P O S T

tutorial101.blogspot.com is © 2010-2021

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy