Catatanweb
Catatanweb
// routes/web.php
Route::get('/product', [ProductController::class, 'index'])->name('product.index');
Route::get('/product/create', [ProductController::class, 'create'])-
>name('product.create');
Route::post('/product', [ProductController::class, 'store'])-
>name('product.store');
// app/Http/Controllers/ProductController.php
class ProductController extends Controller
{
public function index()
{
$products = Product::all();
return view('product.index', compact('products'));
}
// app/Http/Controllers/CustomerController.php
class CustomerController extends Controller
{
public function index()
{
$customers = Customer::all();
return view('customer.index', compact('customers'));
}
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<title>UAT Project</title>
<meta name="robots" content="noindex, nofollow">
<link href="{{ asset('assets/img/favicon.png') }}" rel="icon">
<link href="{{ asset('assets/vendor/bootstrap/css/bootstrap.min.css') }}"
rel="stylesheet">
<link href="{{ asset('assets/vendor/bootstrap-icons/bootstrap-icons.css') }}"
rel="stylesheet">
<link href="{{ asset('assets/css/style.css') }}" rel="stylesheet">
</head>
<body>
<header id="header" class="header fixed-top d-flex align-items-center">
<div class="d-flex align-items-center justify-content-between">
<a href="index.html" class="logo d-flex align-items-center">
<img src="{{ asset('assets/img/logo.png') }}" alt="">
<span class="d-none d-lg-block">NiceAdmin</span>
</a>
<i class="bi bi-list toggle-sidebar-btn"></i>
</div>
</header>
<script src="{{
asset('assets/vendor/bootstrap/js/bootstrap.bundle.min.js') }}"></script>
<script src="{{ asset('assets/js/main.js') }}"></script>
</body>
</html>
// resources/views/product/index.blade.php
@extends('layouts.app')
@section('content')
<div class="pagetitle">
<h1>Products</h1>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a
href="{{ route('product.index') }}">Product</a></li>
<li class="breadcrumb-item active">Index</li>
</ol>
</nav>
</div>
<section class="section">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<h5 class="card-title">Product List</h5>
<a href="{{ route('product.create') }}" class="btn btn-
primary mb-3">Add New Product</a>
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Name</th>
<th scope="col">Stock</th>
</tr>
</thead>
<tbody>
@foreach ($products as $product)
<tr>
<th scope="row">{{ $loop->iteration }}</th>
<td>{{ $product->name }}</td>
<td>{{ $product->stock }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</section>
@endsection
// resources/views/product/create.blade.php
@extends('layouts.app')
@section('content')
<div class="pagetitle">
<h1>Add New Product</h1>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a
href="{{ route('product.index') }}">Product</a></li>
<li class="breadcrumb-item active">Create</li>
</ol>
</nav>
</div>
<section class="section">
<div class="row">
<div class="col-lg-6">
<div class="card">
<div class="card-body">
<h5 class="card-title">Product Form</h5>
<form action="{{ route('product.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="name" class="form-label">Name</label>
<input type="text" class="form-control" id="name"
name="name" required>
</div>
<div class="mb-3">
<label for="stock" class="form-label">Stock</label>
<input type="number" class="form-control"
id="stock" name="stock" required>
</div>
<button type="submit" class="btn
btn-primary">Save</button>
</form>
</div>
</div>
</div>
</div>
</section>
@endsection
// resources/views/customer/index.blade.php
@extends('layouts.app')
@section('content')
<div class="pagetitle">
<h1>Customers</h1>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a
href="{{ route('customer.index') }}">Customer</a></li>
<li class="breadcrumb-item active">Index</li>
</ol>
</nav>
</div>
<section class="section">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<h5 class="card-title">Customer List</h5>
<a href="{{ route('customer.create') }}" class="btn btn-
primary mb-3">Add New Customer</a>
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Name</th>
<th scope="col">Phone</th>
</tr>
</thead>
<tbody>
@foreach ($customers as $customer)
<tr>
<th scope="row">{{ $loop->iteration }}</th>
<td>{{ $customer->name }}</td>
<td>{{ $customer->phone }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</section>
@endsection
// resources/views/customer/create.blade.php
@extends('layouts.app')
@section('content')
<div class="pagetitle">
<h1>Add New Customer</h1>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a
href="{{ route('customer.index') }}">Customer</a></li>
<li class="breadcrumb-item active">Create</li>
</ol>
</nav>
</div>
<section class="section">
<div class="row">
<div class="col-lg-6">
<div class="card">
<div class="card-body">
<h5 class="card-title">Customer Form</h5>
<form action="{{ route('customer.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="name" class="form-label">Name</label>
<input type="text" class="form-control" id="name"
name="name" required>
</div>
<div class="mb-3">
<label for="phone" class="form-label">Phone</label>
<input type="text" class="form-control" id="phone"
name="phone" required>
</div>
<button type="submit" class="btn
btn-primary">Save</button>
</form>
</div>
</div>
</div>
</div>
</section>
@endsection