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

Catatanweb

Uploaded by

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

Catatanweb

Uploaded by

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

```php

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

Route::get('/customer', [CustomerController::class, 'index'])-


>name('customer.index');
Route::get('/customer/create', [CustomerController::class, 'create'])-
>name('customer.create');
Route::post('/customer', [CustomerController::class, 'store'])-
>name('customer.store');

// app/Http/Controllers/ProductController.php
class ProductController extends Controller
{
public function index()
{
$products = Product::all();
return view('product.index', compact('products'));
}

public function create()


{
return view('product.create');
}

public function store(Request $request)


{
$product = new Product();
$product->name = $request->input('name');
$product->stock = $request->input('stock');
$product->save();
return redirect()->route('product.index');
}
}

// app/Http/Controllers/CustomerController.php
class CustomerController extends Controller
{
public function index()
{
$customers = Customer::all();
return view('customer.index', compact('customers'));
}

public function create()


{
return view('customer.create');
}

public function store(Request $request)


{
$customer = new Customer();
$customer->name = $request->input('name');
$customer->phone = $request->input('phone');
$customer->save();
return redirect()->route('customer.index');
}
}

// resources/views/layouts/app.blade.php (NiceAdmin template)


<!DOCTYPE html>
<html lang="en">

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

<aside id="sidebar" class="sidebar">


<ul class="sidebar-nav" id="sidebar-nav">
<li class="nav-item">
<a class="nav-link " href="{{ route('product.index') }}">
<i class="bi bi-grid"></i>
<span>Products</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link " href="{{ route('customer.index') }}">
<i class="bi bi-person"></i>
<span>Customers</span>
</a>
</li>
</ul>
</aside>

<main id="main" class="main">


@yield('content')
</main>

<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

You might also like