Browse Source

update QR sudah terbuat

master
Gunawan19621 1 year ago
parent
commit
afdf9575e9
  1. 126
      app/Http/Controllers/M_assetController.php
  2. 3
      composer.json
  3. 174
      composer.lock
  4. 3
      database/migrations/2023_09_20_163618_create_m_assets_table.php
  5. 20
      resources/views/MasterData/asset.blade.php
  6. 61
      resources/views/MasterData/asset/show.blade.php
  7. 3
      resources/views/dashboard/index.blade.php
  8. 2
      resources/views/layouts/main.blade.php
  9. 13
      routes/web.php

126
app/Http/Controllers/M_assetController.php

@ -2,14 +2,17 @@
namespace App\Http\Controllers;
use App\Exports\AssetExport;
use Dompdf\Dompdf;
use App\Models\m_asset;
use Barryvdh\DomPDF\PDF;
use Dompdf\Dompdf;
use App\Models\m_warehouse;
use App\Exports\AssetExport;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Maatwebsite\Excel\Facades\Excel;
use Illuminate\Support\Facades\Storage;
// use SimpleSoftwareIO\QrCode\Facades\QrCode;
use SimpleSoftwareIO\QrCode\Facades\QrCode;
class M_assetController extends Controller
{
@ -36,32 +39,122 @@ class M_assetController extends Controller
*/
// public function store(Request $request)
// {
// $latestAsset = \App\Models\m_asset::latest()->first();
// // Mendapatkan tahun saat ini
// $currentYear = date("Y");
// // Menghitung nomor urut untuk kode barang
// if ($latestAsset == null) {
// // Kode pertama
// $nomorUrut = 1;
// } else {
// // Kode berikutnya
// $lastCode = substr($latestAsset->seri, 7);
// $nomorUrut = intval($lastCode) + 1;
// }
// // Menggabungkan semua komponen kode barang
// $seri = 'AST' . $currentYear . str_pad($nomorUrut, STR_PAD_LEFT);
// // Validasi input
// $request->validate([
// 'name' => 'required',
// 'description' => 'required',
// 'warehouse_id' => 'required',
// 'date' => 'required',
// 'qr_count' => '',
// ]);
// try {
// $currentUser = Auth::user();
// // Menyiapkan data untuk disimpan
// $validatedData = $request->except('_token');
// $validatedData['seri'] = $seri;
// $validatedData['created_by'] = $currentUser->id; // Menambahkan ID pengguna sebagai created_by
// $validatedData['updated_by'] = $currentUser->id; // Menambahkan ID pengguna sebagai updated_by
// // Menyimpan data ke dalam database
// $newAsset = \App\Models\m_asset::create($validatedData);
// // Membuat QR code dan menyimpannya ke dalam basis data
// $dataForQR = [
// 'seri' => $newAsset->seri,
// 'name' => $newAsset->name,
// // ... tambahkan lebih banyak data sesuai kebutuhan ...
// ];
// $qrCode = QrCode::size(300)->generate(json_encode($dataForQR));
// // Menyimpan QR code ke dalam kolom 'qr_code' di tabel asset (perbaikan)
// $newAsset->update(['qr_count' => $qrCode]);
// return redirect()->back()->with('success', 'Data asset berhasil ditambah.');
// } catch (\Throwable $th) {
// return redirect()->back()->with('error', 'Data asset gagal ditambah.');
// }
// }
// public function store(Request $request)
// {
// $latestAsset = \App\Models\m_asset::latest()->first();
// // Mendapatkan tahun saat ini
// $currentYear = date("Y");
// // Menghitung nomor urut untuk kode barang
// if ($latestAsset == null) {
// // Kode pertama
// $nomorUrut = 1;
// } else {
// // Kode berikutnya
// $lastCode = substr($latestAsset->seri, 7);
// $nomorUrut = intval($lastCode) + 1;
// }
// // Menggabungkan semua komponen kode barang
// $seri = 'AST' . $currentYear . str_pad($nomorUrut, STR_PAD_LEFT);
// // Validasi input
// $request->validate([
// 'name' => 'required',
// 'description' => 'required',
// 'warehouse_id' => 'required',
// 'date' => 'required',
// 'qr_count' => 'required',
// 'qr_count' => '',
// ]);
// // dd($request);
// try {
// $currentUser = Auth::user();
// // Menyiapkan data untuk disimpan
// $validatedData = $request->except('_token');
// $validatedData['seri'] = $seri;
// $validatedData['created_by'] = $currentUser->id; // Menambahkan ID pengguna sebagai created_by
// $validatedData['updated_by'] = $currentUser->id; // Menambahkan ID pengguna sebagai updated_by
// dd($validatedData);
// m_asset::create($validatedData);
// return redirect()->back()->with('success', 'Data barang berhasil ditambah.');
// // Menyimpan data ke dalam database
// $newAsset = \App\Models\m_asset::create($validatedData);
// // Generate QR code and save it as an image in the public directory
// $dataForQR = [
// 'seri' => $newAsset->seri,
// 'name' => $newAsset->name,
// // ... tambahkan lebih banyak data sesuai kebutuhan ...
// ];
// $qrCode = QrCode::format('png')->size(300)->generate(json_encode($dataForQR));
// // Menyimpan QR code sebagai gambar di direktori penyimpanan publik
// $qrCodePath = 'qr_codes/' . $seri . '.png';
// Storage::disk('public')->put($qrCodePath, $qrCode);
// // Menyimpan URL gambar QR code ke dalam kolom 'qr_count'
// $newAsset->update(['qr_count' => $qrCodePath]);
// return redirect()->back()->with('success', 'Data asset berhasil ditambah.');
// } catch (\Throwable $th) {
// return redirect()->back()->with('error', 'Data barang gagal ditambah.');
// return redirect()->back()->with('error', 'Data asset gagal ditambah.');
// }
// return redirect()->back()->with('success', 'Data barang berhasil ditambah.');
// }
public function store(Request $request)
{
// dd($request);
// Mendapatkan produk terbaru
$latestAsset = \App\Models\m_asset::latest()->first();
// Mendapatkan tahun saat ini
$currentYear = date("Y");
@ -82,7 +175,6 @@ class M_assetController extends Controller
'description' => 'required',
'warehouse_id' => 'required',
'date' => 'required',
'qr_count' => 'required',
]);
try {
$currentUser = Auth::user();
@ -107,6 +199,18 @@ class M_assetController extends Controller
public function show($id)
{
// dd('oke');
$asset = m_asset::find($id);
$warehouse = m_warehouse::all();
return view('MasterData.asset.show', compact('asset', 'warehouse'));
}
// Menampilkan data QR
public function QR($id)
{
$asset = m_asset::find($id);
return QrCode::generate(
'Hello, World!',
);
}
/**

3
composer.json

@ -11,7 +11,8 @@
"laravel/framework": "^10.10",
"laravel/sanctum": "^3.2",
"laravel/tinker": "^2.8",
"maatwebsite/excel": "^3.1"
"maatwebsite/excel": "^3.1",
"simplesoftwareio/simple-qrcode": "^4.2"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",

174
composer.lock generated

@ -4,8 +4,62 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "52a35cd301acc3e94305f4149d559010",
"content-hash": "eebc71566b355489dede69a8f81b8d19",
"packages": [
{
"name": "bacon/bacon-qr-code",
"version": "2.0.8",
"source": {
"type": "git",
"url": "https://github.com/Bacon/BaconQrCode.git",
"reference": "8674e51bb65af933a5ffaf1c308a660387c35c22"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Bacon/BaconQrCode/zipball/8674e51bb65af933a5ffaf1c308a660387c35c22",
"reference": "8674e51bb65af933a5ffaf1c308a660387c35c22",
"shasum": ""
},
"require": {
"dasprid/enum": "^1.0.3",
"ext-iconv": "*",
"php": "^7.1 || ^8.0"
},
"require-dev": {
"phly/keep-a-changelog": "^2.1",
"phpunit/phpunit": "^7 | ^8 | ^9",
"spatie/phpunit-snapshot-assertions": "^4.2.9",
"squizlabs/php_codesniffer": "^3.4"
},
"suggest": {
"ext-imagick": "to generate QR code images"
},
"type": "library",
"autoload": {
"psr-4": {
"BaconQrCode\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-2-Clause"
],
"authors": [
{
"name": "Ben Scholzen 'DASPRiD'",
"email": "mail@dasprids.de",
"homepage": "https://dasprids.de/",
"role": "Developer"
}
],
"description": "BaconQrCode is a QR code generator for PHP.",
"homepage": "https://github.com/Bacon/BaconQrCode",
"support": {
"issues": "https://github.com/Bacon/BaconQrCode/issues",
"source": "https://github.com/Bacon/BaconQrCode/tree/2.0.8"
},
"time": "2022-12-07T17:46:57+00:00"
},
{
"name": "barryvdh/laravel-dompdf",
"version": "v2.0.1",
@ -219,6 +273,56 @@
],
"time": "2023-08-31T09:50:34+00:00"
},
{
"name": "dasprid/enum",
"version": "1.0.5",
"source": {
"type": "git",
"url": "https://github.com/DASPRiD/Enum.git",
"reference": "6faf451159fb8ba4126b925ed2d78acfce0dc016"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/DASPRiD/Enum/zipball/6faf451159fb8ba4126b925ed2d78acfce0dc016",
"reference": "6faf451159fb8ba4126b925ed2d78acfce0dc016",
"shasum": ""
},
"require": {
"php": ">=7.1 <9.0"
},
"require-dev": {
"phpunit/phpunit": "^7 | ^8 | ^9",
"squizlabs/php_codesniffer": "*"
},
"type": "library",
"autoload": {
"psr-4": {
"DASPRiD\\Enum\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-2-Clause"
],
"authors": [
{
"name": "Ben Scholzen 'DASPRiD'",
"email": "mail@dasprids.de",
"homepage": "https://dasprids.de/",
"role": "Developer"
}
],
"description": "PHP 7.1 enum implementation",
"keywords": [
"enum",
"map"
],
"support": {
"issues": "https://github.com/DASPRiD/Enum/issues",
"source": "https://github.com/DASPRiD/Enum/tree/1.0.5"
},
"time": "2023-08-25T16:18:39+00:00"
},
{
"name": "dflydev/dot-access-data",
"version": "v3.0.2",
@ -3958,6 +4062,74 @@
},
"time": "2021-12-11T13:40:54+00:00"
},
{
"name": "simplesoftwareio/simple-qrcode",
"version": "4.2.0",
"source": {
"type": "git",
"url": "https://github.com/SimpleSoftwareIO/simple-qrcode.git",
"reference": "916db7948ca6772d54bb617259c768c9cdc8d537"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/SimpleSoftwareIO/simple-qrcode/zipball/916db7948ca6772d54bb617259c768c9cdc8d537",
"reference": "916db7948ca6772d54bb617259c768c9cdc8d537",
"shasum": ""
},
"require": {
"bacon/bacon-qr-code": "^2.0",
"ext-gd": "*",
"php": ">=7.2|^8.0"
},
"require-dev": {
"mockery/mockery": "~1",
"phpunit/phpunit": "~9"
},
"suggest": {
"ext-imagick": "Allows the generation of PNG QrCodes.",
"illuminate/support": "Allows for use within Laravel."
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"SimpleSoftwareIO\\QrCode\\QrCodeServiceProvider"
],
"aliases": {
"QrCode": "SimpleSoftwareIO\\QrCode\\Facades\\QrCode"
}
}
},
"autoload": {
"psr-4": {
"SimpleSoftwareIO\\QrCode\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Simple Software LLC",
"email": "support@simplesoftware.io"
}
],
"description": "Simple QrCode is a QR code generator made for Laravel.",
"homepage": "https://www.simplesoftware.io/#/docs/simple-qrcode",
"keywords": [
"Simple",
"generator",
"laravel",
"qrcode",
"wrapper"
],
"support": {
"issues": "https://github.com/SimpleSoftwareIO/simple-qrcode/issues",
"source": "https://github.com/SimpleSoftwareIO/simple-qrcode/tree/4.2.0"
},
"time": "2021-02-08T20:43:55+00:00"
},
{
"name": "symfony/console",
"version": "v6.3.2",

3
database/migrations/2023_09_20_163618_create_m_assets_table.php

@ -19,7 +19,8 @@ return new class extends Migration
$table->bigInteger('warehouse_id')->unsigned();
$table->foreign('warehouse_id')->references('id')->on('m_warehouses');
$table->datetime('date');
$table->integer('qr_count');
// $table->integer('qr_count');
$table->string('qr_count')->nullable();
$table->timestamps();
$table->softDeletes();
$table->string('created_by', 200);

20
resources/views/MasterData/asset.blade.php

@ -57,10 +57,17 @@
<td>{{ $data->description }}</td>
<td>{{ $data->warehouse->name }}</td>
<td>{{ \Carbon\Carbon::parse($data->date)->format('d-m-Y') }}</td>
<td>{{ $data->qr_count }}</td>
<td>
{!! QrCode::size(80)->generate(route('asset.show', $data->id)) !!}
</td>
<td class="text-center">
<a href="{{ route('asset.show', $data->id) }}">
<i class="fa fa-eye mr-2" style="font-size: 20px"></i>
</a>
<a href="#" data-toggle="modal"
data-target="#editDataModal{{ $data['id'] }}">
data-target="#editDataModal{{ $data->id }}">
<i class="fa fa-edit mr-2" style="font-size: 20px"></i>
</a>
<a href="{{ route('hapusAsset.destroy', $data->id) }}"
@ -112,10 +119,10 @@
<input class="form-control" name="date" type="date" id="date"
value="{{ old('date') }}" placeholder="Masukan Tanggal Asset" required>
<label for="qr_count" class="col-form-label">QR_Count:</label>
{{-- <label for="qr_count" class="col-form-label">QR_Count:</label>
<input class="form-control" name="qr_count" type="text" id="qr_count"
value="{{ old('qr_count') }}" placeholder="Masukan Kode QR"
onkeypress="return event.charCode >= 48 && event.charCode <= 57" required>
onkeypress="return event.charCode >= 48 && event.charCode <= 57" required> --}}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Tutup</button>
@ -152,11 +159,6 @@
<label for="description" class="col-form-label">Deskripsi Asset:</label>
<textarea class="form-control" name="description" id="description" placeholder="Masukkan Deskripsi Asset" required>{{ $data->description }}</textarea>
<label for="qr_count" class="col-form-label">QR_Count:</label>
<input class="form-control" name="qr_count" type="text" id="qr_count"
value="{{ $data->qr_count }}" placeholder="Masukan Kode QR"
onkeypress="return event.charCode >= 48 && event.charCode <= 57" required>
<label for="date" class="col-form-label">Tanggal:</label>
<input class="form-control" name="date" type="date" id="date"
value="{{ \Carbon\Carbon::parse($data->date)->format('Y-m-d') }}"

61
resources/views/MasterData/asset/show.blade.php

@ -0,0 +1,61 @@
@extends('layouts.main')
@section('title', 'Setting Platform')
@section('content')
<div class="container-fluid">
<div class="card">
<div class="card-body">
<h1 class="h3 mb-1 text-gray-800 mb-3">Detail Asset</h1>
<hr class="border">
<div class="form-group">
<label for="name" class="col-form-label">Nama Asset:</label>
<input class="form-control" name="name" type="text" id="name" value="{{ $asset->name }}"
placeholder="Masukan Nama Asset" required readonly>
<label for="description" class="col-form-label">Deskripsi Asset:</label>
<textarea class="form-control" name="description" id="description" placeholder="Masukkan Deskripsi Asset" required
readonly>{{ $asset->description }}</textarea>
<label for="qr_count" class="col-form-label">QR:</label>
<div>
{{-- <img src="{{ asset($asset->qr_count) }}" alt="QR Code" /> --}}
{!! QrCode::size(75)->generate(
'Name: ' .
$asset->name .
"\n" .
'Description: ' .
$asset->description .
"\n" .
'QR Code: ' .
$asset->qr_count .
"\n" .
'Date: ' .
$asset->date .
"\n" .
'Warehouse ID: ' .
$asset->warehouse_id,
) !!}
</div>
<label for="date" class="col-form-label">Tanggal:</label>
<input class="form-control" name="date" type="date" id="date"
value="{{ \Carbon\Carbon::parse($asset->date)->format('Y-m-d') }}"
placeholder="Masukan Tanggal Asset" required readonly>
<label for="warehouse_id" class="col-form-label">Gudang:</label>
<select class="form-control" name="warehouse_id" id="warehouse_id" disabled>
<option disabled selected>Pilih Asal Gudang</option>
@foreach ($warehouse as $data_warehouse)
<option value="{{ $data_warehouse->id }}"
@if ($data_warehouse->id == $asset->warehouse_id) selected
@else @endif>
{{ $data_warehouse->name }}</option>
@endforeach
</select>
</div>
<a href="{{ route('asset.index') }}" class="btn btn-primary ">Kembali</a>
</div>
</div>
</div>
@endsection

3
resources/views/dashboard/index.blade.php

@ -81,7 +81,8 @@
style="font-size: 13px;">
<strong>Reminder Pengembalian</strong>
</div>
<div class="h5 mb-0 font-weight-bold text-gray-800" style="font-size: 25px;">28</div>
<div class="h5 mb-0 font-weight-bold text-gray-800" style="font-size: 25px;">
{{ $reminder }}</div>
</div>
<div class="col-auto">
<i class="fas fa-calendar fa-2x text-gray-300"></i>

2
resources/views/layouts/main.blade.php

@ -48,7 +48,7 @@
<footer class="sticky-footer bg-white">
<div class="container my-auto">
<div class="copyright text-center my-auto">
<span>Copyright &copy; Your Website 2021</span>
<span>Copyright &copy; SIOPAS</span>
</div>
</div>
</footer>

13
routes/web.php

@ -7,14 +7,15 @@ use App\Http\Controllers\M_userController;
use App\Http\Controllers\M_assetController;
use App\Http\Controllers\ProductController;
use App\Http\Controllers\ProfileController;
use SimpleSoftwareIO\QrCode\Facades\QrCode;
use App\Http\Controllers\PengadaanController;
use App\Http\Controllers\TransaksiController;
use App\Http\Controllers\WarehouseController;
use App\Http\Controllers\PeminjamanController;
use App\Http\Controllers\BarangMasukController;
use App\Http\Controllers\BarangKeluarController;
use App\Http\Controllers\PengembalianController;
use App\Http\Controllers\SettingPlatformController;
use App\Http\Controllers\WarehouseController;
/*
|--------------------------------------------------------------------------
@ -43,11 +44,12 @@ Route::middleware('auth')->group(function () {
Route::group(['prefix' => 'dashboard'], function () {
//Halaman dashboard
Route::middleware('auth')->get('', function () {
$reminder = asset_status::whereNull('enter_at')->count();
$jumlahAsset = m_asset::count();
$jumlahPeminjaman = asset_status::count();
// $jumlahPengembalian = asset_status::count();
$jumlahPengembalian = asset_status::whereNotNull('enter_at')->count();
return view('dashboard.index', compact('jumlahAsset', 'jumlahPeminjaman', 'jumlahPengembalian'));
return view('dashboard.index', compact('jumlahAsset', 'jumlahPeminjaman', 'jumlahPengembalian', 'reminder'));
});
//Halaman Transaksi
@ -68,6 +70,13 @@ Route::group(['prefix' => 'dashboard'], function () {
Route::get('/hapusAsset/{id}', [M_assetController::class, 'destroy'])->name('hapusAsset.destroy');
Route::get('/assetcetak_pdf', [M_assetController::class, 'cetakpdf'])->name('assetcetakpdf.cetakpdf');
Route::get('/assetexport', [M_assetController::class, 'export'])->name('assetexport.export');
// Route::get('/assetQR{id}', [M_assetController::class, 'QR'])->name('assetQR.QR');
// Route::get('assetQR{id}', function () {
// $path = public_path('qrcode/' . time() . '.png');
// return QrCode::size(300)
// ->generate('A simple example of QR code', $path);
// })->name('assetQR.QR');
//Halaman Manajemen User
Route::middleware('auth')->resource('/user', M_userController::class);

Loading…
Cancel
Save