SESSION:
<?php
use Illuminate\Http\Request;
use DB;
use Session;
if (session()->has('id_order')) {
$id_order = Session::get('id_order');
}
$id_pengguna = Session::get('id_pengguna');
protected function LoginPengguna(Request $request){
$username = $request->username;
$password = $request->password;
$data = Pengguna::where('username', $username)->first();
if (count((array) $data) > 0) {
if ($password == $data->password) {
Session::put('id_pengguna', $data->id_pengguna);
Session::put('nama_pengguna', $data->nama_pengguna);
Session::put('level', $data->level);
Session::put('telepon', $data->telepon);
Session::put('email', $data->email);
Session::put('username', $data->username);
Session::put('passsword', $data->passsword);
Session::put('status', $data->status);
Session::put('login', TRUE);
if ($data->status == "Aktif") {
return redirect('dashboard_pengguna')->with('success', 'Berhasil Login');
}
} else {
return redirect('login')->with('success', 'Gagal ! Password salah.');
}
} else {
return redirect('login')->with('success', 'Gagal ! Email belum terdaftar.');
}
}
//===============================
public function profil(){
$id_customer = Session::get('id_customer');
$customer = DB::table('tb_customer')->where('id_customer', '=', $id_customer)->first();
return view('customer.profil')->with('customer', $customer);
}
?>
{{ $customer->alamat }}
<form method="post" action="{{ route('customer.updateprofil') }}" enctype="multipart/form-data">
@csrf
<table>
</table>
</form>
WEB
Route::post('updateprofil', 'App\Http\Controllers\DashboardController@updateProfil')->name('customer.updateprofil');
public function updateProfil(Request $request) {
$result = DB::table('tb_customer')
->where('id_customer', $request->id_customer)
->update(
[
'nama_customer' => $request->nama_customer,
'alamat' => $request->alamat,
'telepon' => $request->telepon,
'email' => $request->email,
'username' => $request->username,
'password' => $request->password
]
);
return redirect()->route('customer.profil')->with('pesan', "Update data berhasil");
}
=======================================
<select class="form-control selectpicker" data-live-search="true" name="id_produk">
@foreach ($produks as $getDT)
<option value="{{ $getDT->id_produk }}" @if($getDT->id_produk==$orderdetail->id_produk)
selected
@endif
>{{ $getDT->nama_produk}} |{{ RP($getDT->harga)}}</option>
@endforeach
</select>
=======================================
VIEW order.php:
<a href="orderdetail/{{ $order->id_order }}">DETAIL</a>
<a href="konfirmasi/{{ $konfirmasi->id_konfirmasi }}">DETKONF</a>
<a href="pengiriman/{{ $pengiriman->id_pengiriman }}">DETPENG</a>
WEB.php:
Route::get('orderdetail/{id}', 'App\Http\Controllers\
OrderdetailController@getDetail');
<?php
public function getDetail($id) {
$sql0 = "SELECT * FROM tb_order where `id_order`='" . $id . "'";
$order = DB::select($sql0);
$sql1 = "SELECT * FROM tb_produk,tb_orderdetail WHERE
tb_produk.id_produk=tb_orderdetail.id_produk AND
tb_orderdetail.`id_order`='" . $id . "'";
$orderdetail = DB::select($sql1);
$sql2 = "SELECT * FROM tb_produk where `status`='Tersedia'";
$produk = DB::select($sql2);
$sql3 = "SELECT * FROM tb_konfirmasi where `id_konfirmasi`='" . $id_konfirmasi . "'";
$konfirmasi = DB::select($sql0);
$sql4 = "SELECT * FROM tb_pengiriman where `id_pengiriman`='" . $id_pengiriman . "'";
$pengiriman = DB::select($sql0);
return view('admin.orderdetail.index',
['orders' => $order,
'orderdetails' => $orderdetail,
'produks' => $produk
]);
}
?>
VIEW DETAIL.php
<tbody>
@forelse ($orderdetails as $orderdetail)
<tr>
<td class="text-center">{{$loop->iteration}}</td>
<td><img src="{{ url('ypathfile/'.$orderdetail->gambar)}}" width="100px" height="70px"></td>
<td>{{$orderdetail->nama_produk}}</td>
<td>{{$orderdetail->jumlah}}</td>
<td>{{ RP($orderdetail->subtotal) }}</td>
<td>{{$orderdetail->catatan}}</td>
<td class="text-center">
<div>
<a href="#edit{{ $orderdetail->id }}" data-toggle="modal"><i class="fa fa-edit text-warning"></i></a>
<a href=" #del{{ $orderdetail->id }}" data-toggle="modal"><i class="fa fa-trash text-danger"></i></a>
<a href=" #del{{ $konfirmasi->id_konfirmasi }}" data-toggle="modal"><i class="fa fa-trash text-danger"></i></a>
@include('admin.orderdetail.modal')
</div>
</td>
</tr>
@empty
<td colspan=" 8" class="text-center">Tidak ada data...
</td>
@endforelse
</tbody>
===============================================
@forelse ($konfirmasis as $getDT)
Id_Konfirmasi :{{ ($getDT->id_konfirmasi)}} |{{ $getDT->id_konfirmasi}}<br>
Id_Order :{{ $getDT->id_order}}, pesan {{ $getDT->pesan}}<br>
@empty
@endforelse
==============================================
SAAT LINK KONFIRMASI DI KLIK
<a class="nav-link" href="/konfirmasis">KONFIRMASI</a>
WEB
Route::resource('konfirmasis', 'App\Http\Controllers\KonfirmasiController');
conrotoller KonfirmasiController
public function index() {
$sql = "select * from tb_konfirmasi,tb_order where tb_konfirmasi.id_order=tb_order.id_order";
$konfirmasis = DB::select($sql);
$sql = "select * from tb_order";
$orders = DB::select($sql);
return view('admin.konfirmasi.index', ['konfirmasis' => $konfirmasis, 'orders' => $orders]);
}
@empty
<td colspan=" 8" class="text-center">Tidak ada data...
</td>
@endforelse
</tbody>
===============================================
VIEW1
<a class="nav-link" href="/pengirimans">PENGIRIMAN</a>
WEB
Route::resource('pengirimans', 'App\Http\Controllers\PengirimanController');
CONTROLER: PengirimanController.php
<?php
public function index() {
$sql = "select * from tb_pengiriman";
$pengirimans = DB::select($sql);
$sql = "select * from tb_order";
$orders = DB::select($sql);
$sql = "select * from tb_kurir";
$kurirs = DB::select($sql);
return view('admin.pengiriman.index', ['pengirimans' => $pengirimans, 'orders' => $orders, 'kurirs' => $kurirs]);
}
?>
VIEW2
<tbody>
@forelse ($pengirimans as $pengiriman)
<tr>
<td class="text-center">{{$loop->iteration}}</td>
<td>{{getKurir($pengiriman->id_kurir) }} |IDK-0{{$pengiriman->id_kurir}}</td>
<td>{{ WKTP($pengiriman->tanggal) }} - {{$pengiriman->jam}} WIB</td>
<td>{{$pengiriman->pesan}}</td>
<td>{{$pengiriman->status}}</td>
<td>{{$pengiriman->keterangan}}</td>
<td class="text-center">
<div>
<a href="#edit{{ $pengiriman->id_pengiriman }}" data-toggle="modal"><i class="fa fa-edit text-warning" title="edit"></i></a>
<a href="#del{{ $pengiriman->id_pengiriman }}" data-toggle="modal"><i class="fa fa-trash text-danger" title="hapus"></i></a>
@include('admin.pengiriman.modal')
</div>
</td>
</tr>
@empty
<td colspan="8" class="text-center">Tidak ada data...</td>
@endforelse
</tbody>
<select class="form-control selectpicker" data-live-search="true" name="id_kurir">
@foreach ($kurirs as $kurir)
<option value="{{ $kurir->id_kurir }}">{{ $kurir->nama_kurir}} |{{ $kurir->id_kurir}}</option>
@endforeach
</select>
<?php
function getKurir($kode)
{
$sql = "SELECT `nama_kurir` FROM `tb_kurir` WHERE `id_kurir`= '" .$kode . "'";
$results = DB::select($sql);
$hasil = $results[0]->nama_kurir;
return $hasil;
}
ATAU
@forelse ($orders as $getDT)
Nama :{{ getCustomer($getDT->id_customer)}} |{{ $getDT->id_customer}}<br>
Alamat :{{ $getDT->alamat}}, telp {{ $getDT->telepon}}<br>
@empty
@endforelse
?>
==============================================
SAAT LINK KONFIRMASI DI KLIK
<a class="nav-link" href="/konfirmasis">KONFIRMASI</a>
WEB
Route::resource('konfirmasis', 'App\Http\Controllers\KonfirmasiController');
conrotoller KonfirmasiController.php
<?php
public function index() {
$sql = "select * from tb_konfirmasi,tb_order where tb_konfirmasi.id_order=tb_order.id_order";
$konfirmasis = DB::select($sql);
$sql = "select * from tb_order";
$orders = DB::select($sql);
return view('admin.konfirmasi.index', ['konfirmasis' => $konfirmasis, 'orders' => $orders]);
}
?>
==========================
<form action="{{ route('pengirimans.store') }}" method="POST">
</for>
LANGSUNG KE CONTROLLER TANPA KE WEB
<?php
public function store(Request $request) {
$request->validate([
'pesan' => 'required'
]);
$pengiriman = new Pengiriman();
$pengiriman->tanggal = date("Y-m-d");
$pengiriman->jam = date("H:i:s");
$pengiriman->id_order = $request->id_order;
$pengiriman->id_kurir = $request->id_kurir;
$pengiriman->pesan = $request->pesan;
$pengiriman->status = $request->status;
$pengiriman->keterangan = $request->keterangan;
$pengiriman->save();
return redirect()->route('pengirimans.index')->with('pesan', 'Simpan Data Pengiriman Berhasil.');
}
?>
======================================
VIEW1
<a href="#edit{{ $pengiriman->id_pengiriman }}" data-toggle="modal">
<i class="fa fa-edit text-warning" title="edit"></i></a>
VIEW2
<form action="{{ route('konfirmasis.update',['konfirmasi' => $konfirmasi->konfirmasi]) }}" method="POST" enctype="multipart/form-data">
======================================
DELETE
@forelse ($orders as $order)
<a href="#del{{ $order->id_order }}" data-toggle="modal">DEL</a>
.....
@empty
@endforelse
MODAL:
<form action="{{ route('orders.destroy', $order->id_order) }}" method="POST">
@method('DELETE')
@csrf
<button type="submit" class="btn btn-danger ml-3">Delete</button>
</form>
LANGSUNG KE CONTROLLER
public function destroy($id){
DB::table('tb_order')->where('id_order', '=', $id)->delete();
return redirect()->route('orders.index')->with('pesan', "Hapus data berhasil");
}
======================
ONE TO MANY
<a href="orderdetail/{{ $order->id_order }}">DETAIL</a><br>
================
$id_pengguna = Session::get('id_pengguna');
$pengguna = DB::table('tb_pengguna')->where('id_pengguna', '=', $id_pengguna)->first();
Jumat, 17 Februari 2023
Laravel Kisi-Kisi
Langganan:
Posting Komentar (Atom)
Selisih Waktu Berjalan
Berikut adalah fungsi PHP yang menghitung selisih hari antara tanggal saat ini dengan tanggal 2024-08-22 . Jika tanggal saat ini kurang dari...
-
<?php // <a href='download.php?file=$file' title='Download File'>Download Dokumen</a> $direktori = ...
-
Teman2 ...mungkin sering dapat kode random..... btw ini ada share sedikit ttg membuat soal random.....yang beda disini adalah sy menggunaka...
-
<?php $sql="select `id_admin` from `$tbadmin` order by `id_admin` desc"; $jum= getJum($conn,$sql); $kd="ADM"...
Tidak ada komentar:
Posting Komentar