first
This commit is contained in:
commit
981dbe4524
|
@ -0,0 +1,19 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[docker-compose.yml]
|
||||
indent_size = 4
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=ikan_kering
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
FILESYSTEM_DISK=local
|
||||
QUEUE_CONNECTION=sync
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=mailpit
|
||||
MAIL_PORT=1025
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS="hello@example.com"
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_HOST=
|
||||
PUSHER_PORT=443
|
||||
PUSHER_SCHEME=https
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
VITE_APP_NAME="${APP_NAME}"
|
||||
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
VITE_PUSHER_HOST="${PUSHER_HOST}"
|
||||
VITE_PUSHER_PORT="${PUSHER_PORT}"
|
||||
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
|
||||
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
|
@ -0,0 +1,12 @@
|
|||
* text=auto eol=lf
|
||||
|
||||
*.blade.php diff=html
|
||||
*.css diff=css
|
||||
*.html diff=html
|
||||
*.md diff=markdown
|
||||
*.php diff=php
|
||||
|
||||
/.github export-ignore
|
||||
CHANGELOG.md export-ignore
|
||||
.styleci.yml export-ignore
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
/.phpunit.cache
|
||||
/node_modules
|
||||
/public/build
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/vendor
|
||||
.env
|
||||
.env.backup
|
||||
.env.production
|
||||
.phpunit.result.cache
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
auth.json
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
/.fleet
|
||||
/.idea
|
||||
/.vscode
|
||||
|
Binary file not shown.
|
@ -0,0 +1,67 @@
|
|||
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
|
||||
</p>
|
||||
|
||||
## About Laravel
|
||||
|
||||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
||||
|
||||
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
||||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||
|
||||
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||
|
||||
## Learning Laravel
|
||||
|
||||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
|
||||
|
||||
You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.
|
||||
|
||||
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
||||
|
||||
## Laravel Sponsors
|
||||
|
||||
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).
|
||||
|
||||
### Premium Partners
|
||||
|
||||
- **[Vehikl](https://vehikl.com/)**
|
||||
- **[Tighten Co.](https://tighten.co)**
|
||||
- **[WebReinvent](https://webreinvent.com/)**
|
||||
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
||||
- **[64 Robots](https://64robots.com)**
|
||||
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
|
||||
- **[Cyber-Duck](https://cyber-duck.co.uk)**
|
||||
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
|
||||
- **[Jump24](https://jump24.co.uk)**
|
||||
- **[Redberry](https://redberry.international/laravel/)**
|
||||
- **[Active Logic](https://activelogic.com)**
|
||||
- **[byte5](https://byte5.de)**
|
||||
- **[OP.GG](https://op.gg)**
|
||||
|
||||
## Contributing
|
||||
|
||||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
||||
|
||||
## Security Vulnerabilities
|
||||
|
||||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
||||
|
||||
## License
|
||||
|
||||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*/
|
||||
protected function schedule(Schedule $schedule): void
|
||||
{
|
||||
// $schedule->command('inspire')->hourly();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*/
|
||||
protected function commands(): void
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* The list of the inputs that are never flashed to the session on validation exceptions.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register the exception handling callbacks for the application.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
$this->reportable(function (Throwable $e) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
||||
class GajiKloterExport implements FromCollection, WithHeadings
|
||||
{
|
||||
protected $data;
|
||||
protected $tanggalUnik;
|
||||
|
||||
public function __construct($data, $tanggalUnik)
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->tanggalUnik = $tanggalUnik;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
return collect($this->data)->map(function ($item) {
|
||||
$row = [
|
||||
'Nama' => $item['karyawan']->nama,
|
||||
'Jenis Kelamin' => $item['karyawan']->jenis_kelamin,
|
||||
];
|
||||
|
||||
foreach ($this->tanggalUnik as $tanggal) {
|
||||
$key = \Carbon\Carbon::parse($tanggal)->format('Y-m-d');
|
||||
$label = \Carbon\Carbon::parse($tanggal)->format('d-m-Y');
|
||||
$row[$label] = number_format($item['jam_per_tanggal'][$key] ?? 0, 2);
|
||||
}
|
||||
|
||||
$row['Total Jam Kerja'] = number_format($item['total_jam'], 2);
|
||||
$row['Gaji per Jam'] = $item['gaji_per_jam'];
|
||||
$row['Total Gaji'] = $item['total_gaji'];
|
||||
|
||||
return $row;
|
||||
});
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
$headings = ['Nama', 'Jenis Kelamin'];
|
||||
foreach ($this->tanggalUnik as $tanggal) {
|
||||
$headings[] = \Carbon\Carbon::parse($tanggal)->format('d-m-Y');
|
||||
}
|
||||
return array_merge($headings, ['Total Jam Kerja', 'Gaji per Jam', 'Total Gaji']);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
||||
class LaporanBarangExport implements FromCollection, WithHeadings
|
||||
{
|
||||
protected $barangs;
|
||||
|
||||
public function __construct($barangs)
|
||||
{
|
||||
$this->barangs = $barangs;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
return $this->barangs->map(function ($b) {
|
||||
return [
|
||||
'kode' => $b->produk->kode ?? $b->pendukung->kode ?? '-',
|
||||
'nama_barang' => $b->nama_barang,
|
||||
'exp' => optional($b->exp)->format('d-m-Y'),
|
||||
'harga' => $b->harga,
|
||||
'qty' => $b->qty,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return ['Kode', 'Nama Barang', 'Exp', 'Harga', 'Qty'];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
||||
class LaporanKaryawanExport implements FromCollection, WithHeadings
|
||||
{
|
||||
protected $data;
|
||||
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
return collect($this->data)->map(function ($item, $index) {
|
||||
$gajiPerKloter = collect($item['gaji_per_kloter'])->map(function ($gpk) {
|
||||
return "Kloter ID {$gpk['kloter_id']}: Rp " . number_format($gpk['gaji'], 0, ',', '.') . " ({$gpk['total_jam']} jam)";
|
||||
})->implode("\n"); // dipisah baris di Excel
|
||||
|
||||
return [
|
||||
'No' => $index + 1,
|
||||
'Nama' => $item['karyawan']->nama,
|
||||
'Jenis Kelamin' => $item['karyawan']->jenis_kelamin === 'L' ? 'Laki-laki' : 'Perempuan',
|
||||
'No Telepon' => $item['karyawan']->no_telepon,
|
||||
'Total Jam Kerja' => $item['total_jam_kerja'] . ' Jam',
|
||||
'Gaji per Kloter' => $gajiPerKloter,
|
||||
'Total Gaji' => 'Rp ' . number_format($item['total_gaji'], 0, ',', '.'),
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'No',
|
||||
'Nama Pekerja',
|
||||
'Jenis Kelamin',
|
||||
'No Telepon',
|
||||
'Total Jam Kerja',
|
||||
'Gaji per Kloter',
|
||||
'Total Gaji',
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class LaporanSupplierExport implements FromCollection
|
||||
{
|
||||
protected $data;
|
||||
|
||||
public function __construct(Collection $data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
return $this->data->map(function ($supplier) {
|
||||
return [
|
||||
'Nama' => $supplier->nama,
|
||||
'Kategori' => $supplier->pemasok ? 'Pemasok' : 'Konsumen',
|
||||
'Alamat' => $supplier->alamat,
|
||||
'No Telepon' => $supplier->no_tlp,
|
||||
'No Rekening' => $supplier->no_rekening ?? '-',
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Transaksi;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
||||
class LaporanTransaksiExport implements FromCollection, WithHeadings
|
||||
{
|
||||
protected $tanggalMulai, $tanggalAkhir, $q;
|
||||
|
||||
public function __construct($tanggalMulai, $tanggalAkhir, $q = null)
|
||||
{
|
||||
$this->tanggalMulai = $tanggalMulai;
|
||||
$this->tanggalAkhir = $tanggalAkhir;
|
||||
$this->q = $q;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$query = Transaksi::with([
|
||||
'barang.produk',
|
||||
'barang.pendukung',
|
||||
'supplier',
|
||||
'pemasukan',
|
||||
'pengeluaran'
|
||||
]);
|
||||
|
||||
if ($this->tanggalMulai && $this->tanggalAkhir) {
|
||||
$query->whereBetween('waktu_transaksi', [
|
||||
$this->tanggalMulai . ' 00:00:00',
|
||||
$this->tanggalAkhir . ' 23:59:59'
|
||||
]);
|
||||
}
|
||||
|
||||
if ($this->q) {
|
||||
$search = $this->q;
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->whereHas('barang', fn($q1) => $q1->where('nama_barang', 'like', "%$search%"))
|
||||
->orWhereHas('supplier', fn($q2) => $q2->where('nama', 'like', "%$search%"))
|
||||
->orWhereHas('barang.produk', fn($q3) => $q3->where('kode', 'like', "%$search%"))
|
||||
->orWhereHas('barang.pendukung', fn($q4) => $q4->where('kode', 'like', "%$search%"))
|
||||
->orWhereHas('pemasukan', fn($q5) => $q5->where('kode', 'like', "%$search%"))
|
||||
->orWhereHas('pengeluaran', fn($q6) => $q6->where('kode', 'like', "%$search%"));
|
||||
});
|
||||
}
|
||||
|
||||
$transaksis = $query->orderBy('waktu_transaksi')->get();
|
||||
|
||||
$totalSebelumnya = 0;
|
||||
|
||||
return $transaksis->map(function ($trx) use (&$totalSebelumnya) {
|
||||
$kodeBarang = $trx->barang->produk->kode ?? $trx->barang->pendukung->kode ?? '-';
|
||||
$masuk = $trx->pemasukan_id ? $trx->jumlahRp : 0;
|
||||
$keluar = $trx->pengeluaran_id ? $trx->jumlahRp : 0;
|
||||
|
||||
$totalSekarang = $totalSebelumnya + $masuk - $keluar;
|
||||
$totalSebelumnya = $totalSekarang;
|
||||
|
||||
return [
|
||||
'Waktu' => $trx->waktu_transaksi,
|
||||
'Kode Transaksi' => $trx->pemasukan->kode ?? $trx->pengeluaran->kode ?? '-',
|
||||
'Kode Barang' => $kodeBarang,
|
||||
'Supplier' => $trx->supplier->nama ?? '-',
|
||||
'Nama Barang' => $trx->barang->nama_barang ?? '-',
|
||||
'Qty' => $trx->qtyHistori ?? 0,
|
||||
'Masuk' => $masuk,
|
||||
'Keluar' => $keluar,
|
||||
'Total' => $totalSekarang,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Waktu',
|
||||
'Kode Transaksi',
|
||||
'Kode Barang',
|
||||
'Supplier',
|
||||
'Nama Barang',
|
||||
'Qty',
|
||||
'Masuk',
|
||||
'Keluar',
|
||||
'Total'
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
|
||||
class AuthenticatedSessionController extends Controller
|
||||
{
|
||||
// Fungsi login
|
||||
public function store(Request $request)
|
||||
{
|
||||
// Validasi data login
|
||||
$request->validate([
|
||||
'email' => ['required', 'email'],
|
||||
'password' => ['required'],
|
||||
]);
|
||||
|
||||
// Proses login
|
||||
if (Auth::attempt($request->only('email', 'password'))) {
|
||||
$request->session()->regenerate();
|
||||
|
||||
// Redirect berdasarkan role user
|
||||
return redirect()->intended(RouteServiceProvider::redirectToByRole(Auth::user()));
|
||||
}
|
||||
|
||||
// Jika login gagal
|
||||
return back()->withErrors([
|
||||
'email' => 'The provided credentials do not match our records.',
|
||||
]);
|
||||
}
|
||||
|
||||
// Fungsi logout
|
||||
public function destroy(Request $request)
|
||||
{
|
||||
Auth::logout();
|
||||
|
||||
$request->session()->invalidate();
|
||||
$request->session()->regenerateToken();
|
||||
|
||||
return redirect('/');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
public function create()
|
||||
{
|
||||
return view('register');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|string|email|max:255|unique:users',
|
||||
'password' => 'required|string|min:6|confirmed',
|
||||
'role' => 'required|in:operator,pimpinan',
|
||||
]);
|
||||
|
||||
User::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make($request->password),
|
||||
'role' => $request->role,
|
||||
]);
|
||||
|
||||
return redirect()->route('login')->with('success', 'Registrasi berhasil. Silakan login.');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,246 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Barang;
|
||||
use App\Models\BarangProduk;
|
||||
use App\Models\BarangPendukung;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class BarangController extends Controller
|
||||
{
|
||||
// Menampilkan daftar barang
|
||||
public function index(Request $request)
|
||||
{
|
||||
$filter = $request->query('filter');
|
||||
$nama = $request->query('nama');
|
||||
|
||||
$barangs = Barang::with(['produk', 'pendukung'])->get();
|
||||
|
||||
$barangSudahAda = session('barangSudahAda', false);
|
||||
$namaBarang = session('nama_barang', '');
|
||||
|
||||
// Filter hanya jika $filter ada dan valid
|
||||
if (in_array($filter, ['produk', 'pendukung'])) {
|
||||
$barangs = $barangs->filter(function ($barang) use ($filter) {
|
||||
return $barang->{$filter}; // hanya tampilkan yang memiliki relasi produk/pendukung
|
||||
});
|
||||
$newKode = $this->generateKodeBaru($filter);
|
||||
} else {
|
||||
// Jika tidak ada filter atau tidak valid, tampilkan semua data dan jangan generate kode
|
||||
$newKode = null;
|
||||
}
|
||||
|
||||
// Filter berdasarkan nama (jika ada)
|
||||
if ($nama) {
|
||||
$barangs = $barangs->filter(function ($barang) use ($nama) {
|
||||
return stripos($barang->nama_barang, $nama) !== false;
|
||||
});
|
||||
}
|
||||
|
||||
// Urutkan: produk (kode PRD) lebih dulu, lalu pendukung (kode PND)
|
||||
$barangs = $barangs->sortBy(function ($barang) {
|
||||
return $barang->produk ? '1' . $barang->produk->kode
|
||||
: ($barang->pendukung ? '2' . $barang->pendukung->kode : '9');
|
||||
})->values();
|
||||
|
||||
return view('operator.barang.index',
|
||||
compact('barangs', 'filter', 'newKode', 'barangSudahAda', 'namaBarang')
|
||||
);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'filter' => 'required|in:produk,pendukung',
|
||||
'nama_barang' => 'required|string|max:255',
|
||||
'qty' => 'required|integer|min:0',
|
||||
'harga' => 'required|numeric|min:0',
|
||||
'exp' => $request->filter === 'produk' ? 'required|date|after:today' : 'nullable|date',
|
||||
]);
|
||||
|
||||
// Cari apakah barang dengan nama dan kategori yang sama sudah ada
|
||||
$existingBarang = Barang::whereRaw('LOWER(nama_barang) = ?', [strtolower($request->nama_barang)]) // case-insensitive search
|
||||
->whereHas($request->filter) // produk atau pendukung
|
||||
->first();
|
||||
|
||||
$barangSudahAda = $existingBarang !== null;
|
||||
|
||||
if ($existingBarang) {
|
||||
// Update qty dan harga terakhir
|
||||
$existingBarang->qty += $request->qty;
|
||||
$existingBarang->harga = $request->harga;
|
||||
$existingBarang->exp = $request->filter === 'produk' ? $request->exp : null;
|
||||
$existingBarang->save();
|
||||
|
||||
return redirect()->route('barang.index', [
|
||||
'filter' => $request->filter,
|
||||
])->with('warning', 'Barang sudah ada, data akan digabungkan!') // flash session
|
||||
->with('barangSudahAda', true)
|
||||
->with('nama_barang', $request->nama_barang);
|
||||
}
|
||||
|
||||
$barang = Barang::create([
|
||||
'nama_barang' => $request->nama_barang,
|
||||
'qty' => $request->qty,
|
||||
'harga' => $request->harga,
|
||||
'exp' => $request->exp,
|
||||
]);
|
||||
|
||||
// Generate kode baru untuk produk atau pendukung
|
||||
$kodeBaru = $this->generateKodeBaru($request->filter);
|
||||
|
||||
// Tambahkan sebagai produk dengan kode auto
|
||||
if ($request->filter === 'produk') {
|
||||
BarangProduk::create([
|
||||
'barang_id' => $barang->id,
|
||||
'kode' => $kodeBaru,
|
||||
]);
|
||||
} else {
|
||||
BarangPendukung::create([
|
||||
'barang_id' => $barang->id,
|
||||
'kode' => $kodeBaru,
|
||||
]);
|
||||
}
|
||||
|
||||
return redirect()->route('barang.index', ['filter' => $request->filter])
|
||||
->with('success', 'Barang ' . $request->filter . ' berhasil ditambahkan');
|
||||
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$barang = Barang::with(['produk', 'pendukung'])->findOrFail($id);
|
||||
|
||||
$request->validate([
|
||||
'nama_barang' => 'required|string|max:255',
|
||||
'kategori' => 'required|in:produk,pendukung',
|
||||
'exp' => 'nullable|date',
|
||||
'harga' => 'required|numeric|min:0',
|
||||
]);
|
||||
|
||||
$kategori_lama = $barang->produk ? 'produk' : 'pendukung';
|
||||
$kategori_baru = $request->kategori;
|
||||
|
||||
// Cek apakah melibatkan 'produk'
|
||||
$melibatkanProduk = $kategori_lama === 'produk' || $kategori_baru === 'produk';
|
||||
|
||||
// Jika kategori berubah dan melibatkan produk, tapi tidak ada konfirmasi, maka tolak
|
||||
if ($kategori_lama !== $kategori_baru && $melibatkanProduk && !$request->has('confirm_produk')) {
|
||||
return back()->with('error', 'Perpindahan kategori ke/dari Produk perlu konfirmasi.');
|
||||
}
|
||||
|
||||
// Update barang utama
|
||||
$barang->nama_barang = $request->nama_barang;
|
||||
$barang->exp = $request->exp;
|
||||
$barang->harga = $request->harga;
|
||||
$barang->save();
|
||||
|
||||
// Hapus relasi lama
|
||||
if ($kategori_lama === 'pendukung' && $barang->pendukung) {
|
||||
$barang->pendukung->delete();
|
||||
} elseif ($kategori_lama === 'produk' && $barang->produk) {
|
||||
$barang->produk->delete();
|
||||
}
|
||||
|
||||
// Tambah relasi baru sesuai kategori
|
||||
$kodeBaru = $this->generateKodeBaru($kategori_baru);
|
||||
|
||||
if ($kategori_baru === 'produk') {
|
||||
BarangProduk::create([
|
||||
'barang_id' => $barang->id,
|
||||
'kode' => $kodeBaru,
|
||||
]);
|
||||
} else {
|
||||
BarangPendukung::create([
|
||||
'barang_id' => $barang->id,
|
||||
'kode' => $kodeBaru,
|
||||
]);
|
||||
}
|
||||
|
||||
return redirect()->route('barang.index', ['filter' => $kategori_baru])
|
||||
->with('success', 'Barang berhasil diperbarui.');
|
||||
}
|
||||
|
||||
public function updateQty(Request $request, $id)
|
||||
{
|
||||
$request->validate([
|
||||
'qty' => 'required|integer|min:0',
|
||||
]);
|
||||
|
||||
$barang = Barang::findOrFail($id);
|
||||
$barang->qty = $request->qty;
|
||||
$barang->save();
|
||||
|
||||
return back()->with('success', 'Stok barang berhasil diperbarui.');
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$barang = Barang::with(['produk', 'pendukung'])->findOrFail($id);
|
||||
|
||||
if ($barang->produk) {
|
||||
$barang->produk->delete();
|
||||
} elseif ($barang->pendukung) {
|
||||
$barang->pendukung->delete();
|
||||
}
|
||||
|
||||
$barang->delete();
|
||||
|
||||
return back()->with('success', 'Barang berhasil dihapus.');
|
||||
}
|
||||
|
||||
public function stokPimpinan()
|
||||
{
|
||||
$barang = Barang::with(['produk', 'pendukung'])->get();
|
||||
return view('pimpinan.stock_barang.index', compact('barang'));
|
||||
}
|
||||
|
||||
public function check(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'nama_barang' => 'required|string',
|
||||
'filter' => 'required|in:produk,pendukung',
|
||||
]);
|
||||
|
||||
$barang = Barang::whereRaw('LOWER(nama_barang) = ?', [strtolower($request->nama_barang)])
|
||||
->whereHas($request->filter) // produk atau pendukung
|
||||
->with($request->filter)
|
||||
->first();
|
||||
|
||||
if ($barang) {
|
||||
return response()->json([
|
||||
'barang_sudah_ada' => true,
|
||||
'nama_barang' => $barang->nama_barang,
|
||||
'kode' => $barang->{$request->filter}->kode ?? null,
|
||||
]);
|
||||
} else {
|
||||
$kodeBaru = $this->generateKodeBaru($request->filter);
|
||||
return response()->json([
|
||||
'barang_sudah_ada' => false,
|
||||
'nama_barang' => $request->nama_barang,
|
||||
'kode' => $kodeBaru,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
private function generateKodeBaru($kategori)
|
||||
{
|
||||
switch ($kategori) {
|
||||
case 'produk':
|
||||
$prefix = 'PRD';
|
||||
$model = BarangProduk::class;
|
||||
break;
|
||||
case 'pendukung':
|
||||
$prefix = 'PDN';
|
||||
$model = BarangPendukung::class;
|
||||
break;
|
||||
default:
|
||||
throw new \Exception("Kategori tidak valid");
|
||||
}
|
||||
|
||||
$lastKode = $model::orderBy('id', 'desc')->first();
|
||||
$lastNumber = $lastKode ? (int)substr($lastKode->kode, 3) : 0;
|
||||
return $prefix . str_pad($lastNumber + 1, 3, '0', STR_PAD_LEFT);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, ValidatesRequests;
|
||||
}
|
|
@ -0,0 +1,171 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Carbon\CarbonPeriod;
|
||||
|
||||
use App\Models\Barang;
|
||||
use App\Models\BarangPendukung;
|
||||
use App\Models\BarangProduk;
|
||||
use App\Models\Transaksi;
|
||||
use App\Models\Pengeluaran;
|
||||
use App\Models\HistoryGajiKloter;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
// Menampilkan dashboard pimpinan.
|
||||
public function pimpinan(Request $request)
|
||||
{
|
||||
$currentYear = now()->year;
|
||||
$start = $request->get('start_date')
|
||||
? Carbon::parse($request->get('start_date'))
|
||||
: Carbon::create($currentYear, 1, 1)->startOfDay();
|
||||
$end = $request->get('end_date')
|
||||
? Carbon::parse($request->get('end_date'))
|
||||
: Carbon::create($currentYear, 12, 31)->endOfDay();
|
||||
|
||||
$kloters = HistoryGajiKloter::whereNotNull('tanggal_awal')
|
||||
->whereNotNull('tanggal_akhir')
|
||||
->orderBy('id', 'desc')
|
||||
->get();
|
||||
|
||||
$query = Transaksi::whereBetween('waktu_transaksi', [$start, $end]);
|
||||
|
||||
$dates = CarbonPeriod::create($start, $end);
|
||||
|
||||
$labels = [];
|
||||
$pendapatanBulanan = [];
|
||||
$pengeluaranBulanan = [];
|
||||
|
||||
foreach ($dates as $date) {
|
||||
$labels[] = $date->format('d M');
|
||||
|
||||
$pendapatan = Transaksi::whereDate('waktu_transaksi', $date)
|
||||
->whereNotNull('pemasukan_id')
|
||||
->sum('jumlahRp');
|
||||
|
||||
$pengeluaran = Transaksi::whereDate('waktu_transaksi', $date)
|
||||
->where(function ($q) {
|
||||
$q->whereNotNull('pengeluaran_id')
|
||||
->orWhereNotNull('history_gaji_kloter_id');
|
||||
})
|
||||
->sum('jumlahRp');
|
||||
|
||||
$pendapatanBulanan[] = $pendapatan;
|
||||
$pengeluaranBulanan[] = $pengeluaran;
|
||||
}
|
||||
|
||||
$bulanAktif = $start->translatedFormat('d M Y') . ' - ' . $end->translatedFormat('d M Y');
|
||||
|
||||
$totalPendapatan = Transaksi::whereBetween('waktu_transaksi', [$start, $end])
|
||||
->whereNotNull('pemasukan_id')
|
||||
->sum('jumlahRp');
|
||||
|
||||
$totalPengeluaran = Transaksi::whereBetween('waktu_transaksi', [$start, $end])
|
||||
->where(function ($q) {
|
||||
$q->whereNotNull('pengeluaran_id')
|
||||
->orWhereNotNull('history_gaji_kloter_id');
|
||||
})
|
||||
->sum('jumlahRp');
|
||||
|
||||
$keuangan = [
|
||||
'pendapatan' => $totalPendapatan,
|
||||
'pengeluaran' => $totalPengeluaran
|
||||
];
|
||||
|
||||
return view('dashboard.pimpinan', compact(
|
||||
'labels',
|
||||
'pendapatanBulanan',
|
||||
'pengeluaranBulanan',
|
||||
'keuangan',
|
||||
'bulanAktif',
|
||||
'kloters'
|
||||
));
|
||||
}
|
||||
|
||||
// Menampilkan dashboard operator
|
||||
public function operator()
|
||||
{
|
||||
// Ambil 5 data barang terbaru
|
||||
$barangTerbaru = Barang::with(['produk', 'pendukung'])
|
||||
->latest()
|
||||
->take(5)
|
||||
->get();
|
||||
|
||||
// Ambil 5 transaksi terbaru
|
||||
$transaksiTerbaru = Transaksi::with(['barang', 'pemasukan', 'pengeluaran', 'historyGajiKloter'])
|
||||
->orderBy('waktu_transaksi', 'desc')
|
||||
->take(5)
|
||||
->get()
|
||||
->map(function ($trx) {
|
||||
$kategori = $trx->pengeluaran_id === null ? 'Masuk' : 'Keluar';
|
||||
$harga = ($kategori === 'Masuk' ? '+ ' : '- ') . 'Rp ' . number_format($trx->jumlahRp, 0, ',', '.');
|
||||
|
||||
// Tentukan nama transaksi
|
||||
$namaTransaksi = $trx->historyGajiKloter
|
||||
? 'Pembayaran Gaji Kloter #' . $trx->historyGajiKloter->id
|
||||
: ($trx->barang->nama_barang ?? '-');
|
||||
|
||||
return [
|
||||
'waktu' => $trx->waktu_transaksi,
|
||||
'nama_barang' => $namaTransaksi,
|
||||
'kategori' => $kategori,
|
||||
'harga' => $harga,
|
||||
];
|
||||
});
|
||||
|
||||
// Jumlah total barang
|
||||
$jBarang = Barang::sum('qty');
|
||||
$jumlahBarang = number_format($jBarang, 0, ',', '.') . ' kg';
|
||||
|
||||
return view('dashboard.operator', compact('barangTerbaru', 'transaksiTerbaru', 'jumlahBarang'));
|
||||
}
|
||||
|
||||
public function tambahUangMakanHarian()
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
// Ambil barang uang makan
|
||||
$barang = Barang::where('nama_barang', 'like', '%uang makan%')->first();
|
||||
|
||||
if (!$barang) {
|
||||
return back()->with('error', 'Barang uang makan tidak ditemukan.');
|
||||
}
|
||||
|
||||
// Cek apakah stok mencukupi
|
||||
if ($barang->qty < 1) {
|
||||
return back()->with('error', 'Stok uang makan tidak mencukupi.');
|
||||
}
|
||||
|
||||
// Kurangi stok
|
||||
$barang->qty -= 1;
|
||||
$barang->save();
|
||||
|
||||
$pengeluaran = Pengeluaran::create([
|
||||
'kode' => 'KLR' . str_pad(Pengeluaran::max('id') + 1, 3, '0', STR_PAD_LEFT),
|
||||
]);
|
||||
|
||||
Transaksi::create([
|
||||
'barang_id' => $barang->id,
|
||||
'pengeluaran_id' => $pengeluaran->id,
|
||||
'qtyHistori' => 1,
|
||||
'satuan' => 'paket', // satuan statis
|
||||
'jumlahRp' => $barang->harga,
|
||||
'waktu_transaksi' => now(),
|
||||
'supplier_id' => null,
|
||||
]);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return back()->with('success', 'Transaksi uang makan berhasil ditambahkan.');
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
return back()->with('error', 'Gagal menambahkan uang makan: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,263 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Carbon\CarbonPeriod;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Models\Karyawan;
|
||||
use App\Models\Kloter;
|
||||
use App\Models\Presensi;
|
||||
use App\Models\TonIkan;
|
||||
use App\Models\HistoryGajiKloter;
|
||||
use App\Models\Transaksi;
|
||||
use App\Models\Pengeluaran;
|
||||
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Exports\GajiKloterExport;
|
||||
|
||||
class GajiController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$tahun = $request->input('tahun');
|
||||
$status = $request->input('status');
|
||||
|
||||
// $klotersQuery = Kloter::with(['presensis', 'tonIkan'])->orderBy('id', 'desc');
|
||||
$klotersQuery = Kloter::with(['presensis', 'tonIkan'])->orderByDesc('id');
|
||||
$kloterSelesaiIds = HistoryGajiKloter::pluck('kloter_id')->toArray();
|
||||
|
||||
if ($tahun) {
|
||||
$klotersQuery->whereHas('presensis', function ($query) use ($tahun) {
|
||||
$query->whereYear('tanggal', $tahun);
|
||||
});
|
||||
}
|
||||
|
||||
$kloters = $klotersQuery->get();
|
||||
|
||||
// Filter manual untuk status
|
||||
if ($status === 'selesai') {
|
||||
$kloters = $kloters->filter(fn($kloter) =>
|
||||
HistoryGajiKloter::where('kloter_id', $kloter->id)->exists()
|
||||
);
|
||||
} elseif ($status === 'belum') {
|
||||
$kloters = $kloters->filter(fn($kloter) =>
|
||||
!HistoryGajiKloter::where('kloter_id', $kloter->id)->exists()
|
||||
);
|
||||
}
|
||||
|
||||
$tahunList = Presensi::selectRaw('YEAR(tanggal) as tahun')->distinct()->pluck('tahun');
|
||||
|
||||
return view('operator.gaji.index',
|
||||
compact('kloters', 'tahun', 'tahunList', 'status', 'kloterSelesaiIds')
|
||||
);
|
||||
}
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
$search = request('search');
|
||||
|
||||
$kloter = Kloter::with(['presensis.karyawan', 'tonIkan'])->findOrFail($id);
|
||||
$tanggalUnik = $kloter->presensis->pluck('tanggal')->unique()->sort()->values();
|
||||
$dataKaryawan = $kloter->presensis->groupBy('karyawan_id');
|
||||
$banyakPekerja = $dataKaryawan->count();
|
||||
|
||||
$jumlahTon = $kloter->tonIkan->jumlah_ton ?? 0;
|
||||
$hargaPerTon = $kloter->tonIkan->harga_ikan_per_ton ?? 1000000;
|
||||
$gajiPerJam = $banyakPekerja > 0 ? ($jumlahTon * $hargaPerTon) / $banyakPekerja : 0;
|
||||
|
||||
$karyawanWithGaji = [];
|
||||
|
||||
foreach ($dataKaryawan as $karyawanId => $presensis) {
|
||||
$karyawan = $presensis->first()->karyawan;
|
||||
$jamPerTanggal = [];
|
||||
$totalJam = 0;
|
||||
|
||||
foreach ($tanggalUnik as $tanggal) {
|
||||
$presensi = $presensis->firstWhere('tanggal', $tanggal);
|
||||
$jamKerja = 0;
|
||||
|
||||
if ($presensi && $presensi->jam_masuk && $presensi->jam_pulang) {
|
||||
$jamMasuk = strtotime($presensi->jam_masuk);
|
||||
$jamPulang = strtotime($presensi->jam_pulang);
|
||||
$jamKerja = ($jamPulang - $jamMasuk) / 3600;
|
||||
}
|
||||
|
||||
$jamPerTanggal[$tanggal] = $jamKerja;
|
||||
$totalJam += $jamKerja;
|
||||
}
|
||||
|
||||
$totalGaji = $gajiPerJam * $totalJam;
|
||||
if ($karyawan->jenis_kelamin === 'P') {
|
||||
$totalGaji *= 0.6; // potongan 40%
|
||||
}
|
||||
|
||||
$karyawanWithGaji[] = [
|
||||
'karyawan' => $karyawan,
|
||||
'jam_per_tanggal' => $jamPerTanggal,
|
||||
'total_jam' => $totalJam,
|
||||
'gaji_per_jam' => $gajiPerJam,
|
||||
'total_gaji' => $totalGaji,
|
||||
];
|
||||
}
|
||||
|
||||
if ($search) {
|
||||
$karyawanWithGaji = array_filter($karyawanWithGaji, function ($data) use ($search) {
|
||||
return stripos($data['karyawan']->nama, $search) !== false;
|
||||
});
|
||||
}
|
||||
|
||||
return view('operator.gaji.detailGaji', compact(
|
||||
'kloter',
|
||||
'tanggalUnik',
|
||||
'dataKaryawan',
|
||||
'gajiPerJam',
|
||||
'jumlahTon',
|
||||
'hargaPerTon',
|
||||
'karyawanWithGaji'
|
||||
))->with('selectedKloter', $kloter);
|
||||
}
|
||||
|
||||
public function kloterSelesai($id)
|
||||
{
|
||||
$kloter = Kloter::with(['presensis.karyawan', 'tonIkan'])->findOrFail($id);
|
||||
|
||||
if (HistoryGajiKloter::where('kloter_id', $kloter->id)->exists()) {
|
||||
return redirect()->route('gaji.index')->with('error', 'Kloter ini sudah ditandai selesai sebelumnya.');
|
||||
}
|
||||
|
||||
// Ambil data tanggal awal dan akhir dari presensi kloter
|
||||
$tanggalUnik = $kloter->presensis->pluck('tanggal')->unique()->sort()->values();
|
||||
$tanggalAwal = $tanggalUnik->first();
|
||||
$tanggalAkhir = $tanggalUnik->last();
|
||||
|
||||
$dataKaryawan = $kloter->presensis->groupBy('karyawan_id');
|
||||
$banyakPekerja = $dataKaryawan->count();
|
||||
|
||||
$jumlahTon = $kloter->tonIkan->jumlah_ton ?? 0;
|
||||
$hargaPerTon = $kloter->tonIkan->harga_ikan_per_ton ?? 1000000;
|
||||
$gajiPerJam = $banyakPekerja > 0 ? ($jumlahTon * $hargaPerTon) / $banyakPekerja : 0;
|
||||
|
||||
$totalGaji = 0;
|
||||
|
||||
foreach ($dataKaryawan as $presensis) {
|
||||
$karyawan = $presensis->first()->karyawan;
|
||||
|
||||
$totalJam = $presensis->sum(function ($presensi) {
|
||||
return (strtotime($presensi->jam_pulang) - strtotime($presensi->jam_masuk)) / 3600;
|
||||
});
|
||||
|
||||
$gaji = $gajiPerJam * $totalJam;
|
||||
|
||||
if ($karyawan->jenis_kelamin === 'P') {
|
||||
$gaji *= 0.6; // potongan 40%
|
||||
}
|
||||
|
||||
$totalGaji += $gaji;
|
||||
}
|
||||
|
||||
// 1. Simpan ke History Gaji Kloter
|
||||
$historyGaji = HistoryGajiKloter::create([
|
||||
'kloter_id' => $kloter->id,
|
||||
'kode' => 'GK-' . strtoupper(uniqid()),
|
||||
'jml_karyawan' => $banyakPekerja,
|
||||
'total_gaji' => $totalGaji,
|
||||
'waktu' => now(),
|
||||
'tanggal_awal' => $tanggalAwal,
|
||||
'tanggal_akhir' => $tanggalAkhir,
|
||||
]);
|
||||
|
||||
// 2. Buat entri Pengeluaran jika belum ada (PGJxxx)
|
||||
$lastKode = Pengeluaran::where('kode', 'like', 'PGJ%')->orderByDesc('id')->value('kode');
|
||||
$nextNumber = $lastKode && preg_match('/PGJ(\d+)/', $lastKode, $m)
|
||||
? str_pad($m[1] + 1, 3, '0', STR_PAD_LEFT)
|
||||
: '001';
|
||||
|
||||
$kodePengeluaran = 'PGJ' . $nextNumber;
|
||||
|
||||
$pengeluaran = Pengeluaran::create([
|
||||
'kode' => $kodePengeluaran,
|
||||
'nama' => 'Gaji Karyawan',
|
||||
'keterangan' => 'Pembayaran gaji untuk kloter #' . $kloter->id,
|
||||
'tanggal' => now(),
|
||||
]);
|
||||
|
||||
// 3. Simpan ke Transaksi, kaitkan dengan history_gaji_kloter dan pengeluaran
|
||||
Transaksi::create([
|
||||
'pengeluaran_id' => $pengeluaran->id,
|
||||
'history_gaji_kloter_id' => $historyGaji->id,
|
||||
'qtyHistori' => 1,
|
||||
'satuan' => 'kloter',
|
||||
'jumlahRp' => $totalGaji,
|
||||
'waktu_transaksi' => now(),
|
||||
]);
|
||||
|
||||
return redirect()->route('gaji.kloter')->with('success', 'Kloter berhasil diselesaikan dan transaksi gaji dicatat.');
|
||||
}
|
||||
|
||||
|
||||
public function export($id)
|
||||
{
|
||||
$kloter = \App\Models\Kloter::with('tonIkan')->findOrFail($id);
|
||||
|
||||
$presensis = \App\Models\Presensi::with('karyawan')
|
||||
->where('kloter_id', $id)
|
||||
->get();
|
||||
|
||||
$tanggalUnik = $presensis->pluck('tanggal')->unique()->sort()->values();
|
||||
|
||||
$gajiPerJam = 0;
|
||||
$jumlahPekerja = $presensis->pluck('karyawan_id')->unique()->count();
|
||||
|
||||
$jumlahTon = $kloter->tonIkan->jumlah_ton ?? 0;
|
||||
$hargaPerTon = $kloter->tonIkan->harga_ikan_per_ton ?? 1000000;
|
||||
|
||||
if ($jumlahPekerja > 0) {
|
||||
$gajiPerJam = ($jumlahTon * $hargaPerTon) / $jumlahPekerja;
|
||||
}
|
||||
|
||||
$data = [];
|
||||
|
||||
foreach ($presensis->groupBy('karyawan_id') as $karyawanId => $presensiKaryawan) {
|
||||
$karyawan = $presensiKaryawan->first()->karyawan;
|
||||
$jamPerTanggal = [];
|
||||
|
||||
foreach ($presensiKaryawan as $p) {
|
||||
$key = \Carbon\Carbon::parse($p->tanggal)->format('Y-m-d');
|
||||
|
||||
$jamKerja = 0;
|
||||
if ($p->jam_masuk && $p->jam_pulang) {
|
||||
$jamMasuk = strtotime($p->jam_masuk);
|
||||
$jamPulang = strtotime($p->jam_pulang);
|
||||
$jamKerja = ($jamPulang - $jamMasuk) / 3600;
|
||||
}
|
||||
|
||||
$jamPerTanggal[$key] = $jamKerja;
|
||||
}
|
||||
|
||||
$totalJam = array_sum($jamPerTanggal);
|
||||
|
||||
$gajiPerJamKaryawan = $karyawan->jenis_kelamin == 'Perempuan'
|
||||
? $gajiPerJam * 0.6
|
||||
: $gajiPerJam;
|
||||
|
||||
$totalGaji = $gajiPerJamKaryawan * $totalJam;
|
||||
|
||||
$data[] = [
|
||||
'karyawan' => $karyawan,
|
||||
'jam_per_tanggal' => $jamPerTanggal,
|
||||
'total_jam' => $totalJam,
|
||||
'gaji_per_jam' => round($gajiPerJamKaryawan),
|
||||
'total_gaji' => round($totalGaji),
|
||||
];
|
||||
|
||||
// dd($data, $tanggalUnik);
|
||||
|
||||
}
|
||||
|
||||
return Excel::download(new GajiKloterExport($data, $tanggalUnik), 'detail_gaji_' . $kloter->nama_kloter . '.xlsx');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Karyawan;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class KaryawanController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$nama = $request->query('nama');
|
||||
$gender = $request->query('gender');
|
||||
|
||||
$karyawans = Karyawan::query();
|
||||
|
||||
// Filter nama
|
||||
if ($nama) {
|
||||
$karyawans->where('nama', 'like', '%' . $nama . '%');
|
||||
}
|
||||
|
||||
// Filter jenis kelamin
|
||||
if ($gender) {
|
||||
$karyawans->where('jenis_kelamin', $gender);
|
||||
}
|
||||
|
||||
$karyawans = $karyawans->get();
|
||||
|
||||
return view('operator.karyawan.index', compact('karyawans'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'nama' => 'required|string|max:255',
|
||||
'jenis_kelamin' => 'required|in:L,P',
|
||||
'no_telepon' => 'nullable|string|max:20',
|
||||
]);
|
||||
|
||||
Karyawan::create([
|
||||
'nama' => $request->nama,
|
||||
'jenis_kelamin' => $request->jenis_kelamin,
|
||||
'no_telepon' => $request->no_telepon,
|
||||
]);
|
||||
|
||||
return redirect()->route('karyawan.index')->with('success', 'Karyawan berhasil ditambahkan.');
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$request->validate([
|
||||
'nama' => 'required|string|max:255',
|
||||
'jenis_kelamin' => 'required|in:L,P',
|
||||
'no_telepon' => 'nullable|string|max:20',
|
||||
]);
|
||||
|
||||
$karyawan = Karyawan::findOrFail($id);
|
||||
$karyawan->update([
|
||||
'nama' => $request->nama,
|
||||
'jenis_kelamin' => $request->jenis_kelamin,
|
||||
'no_telepon' => $request->no_telepon,
|
||||
]);
|
||||
|
||||
return redirect()->route('karyawan.index')->with('success', 'Karyawan berhasil diperbarui.');
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$karyawan = Karyawan::findOrFail($id);
|
||||
$karyawan->delete();
|
||||
|
||||
return redirect()->route('karyawan.index')->with('success', 'Karyawan berhasil dihapus.');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,326 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
use App\Models\Barang;
|
||||
use App\Models\Supplier;
|
||||
use App\Models\Karyawan;
|
||||
use App\Models\Presensi;
|
||||
use App\Models\Kloter;
|
||||
use App\Models\TonIkan;
|
||||
use App\Models\Transaksi;
|
||||
|
||||
use App\Exports\LaporanBarangExport;
|
||||
use App\Exports\LaporanKaryawanExport;
|
||||
use App\Exports\LaporanSupplierExport;
|
||||
use App\Exports\LaporanTransaksiExport;
|
||||
|
||||
class LaporanController extends Controller
|
||||
{
|
||||
public function barang(Request $request)
|
||||
{
|
||||
$filter = $request->query('filter');
|
||||
$nama = $request->query('nama');
|
||||
$isAjax = $request->ajax();
|
||||
$isExport = $request->query('export') === 'excel';
|
||||
|
||||
$barangs = Barang::with(['produk', 'pendukung']);
|
||||
|
||||
if (in_array($filter, ['produk', 'pendukung'])) {
|
||||
$barangs->whereHas($filter);
|
||||
}
|
||||
|
||||
if ($nama) {
|
||||
$barangs->where('nama_barang', 'like', '%' . $nama . '%');
|
||||
}
|
||||
|
||||
$barangs = $barangs->get()->sortBy(function ($barang) {
|
||||
if ($barang->produk) {
|
||||
return '1' . $barang->produk->kode;
|
||||
} elseif ($barang->pendukung) {
|
||||
return '2' . $barang->pendukung->kode;
|
||||
} else {
|
||||
return '9';
|
||||
}
|
||||
})->values();
|
||||
|
||||
if ($isExport) {
|
||||
return Excel::download(new LaporanBarangExport($barangs), 'laporan-barang.xlsx');
|
||||
}
|
||||
|
||||
if ($isAjax) {
|
||||
return view('pimpinan.laporan_barang._table', compact('barangs'))->render();
|
||||
}
|
||||
|
||||
return view('pimpinan.laporan_barang.index', compact('barangs', 'filter', 'nama'));
|
||||
}
|
||||
|
||||
public function karyawan(Request $request)
|
||||
{
|
||||
$filter = $request->input('filter', 'minggu_ini');
|
||||
$nama = $request->input('nama');
|
||||
|
||||
switch ($filter) {
|
||||
case 'kloter_terbaru':
|
||||
// Ambil kloter yang memiliki presensi dengan tanggal paling akhir
|
||||
$presensiTerbaru = Presensi::latest('tanggal')->first();
|
||||
|
||||
if ($presensiTerbaru && $presensiTerbaru->kloter) {
|
||||
$kloterTerbaru = $presensiTerbaru->kloter;
|
||||
|
||||
// Gunakan accessor dari model Kloter
|
||||
$startDate = Carbon::parse($kloterTerbaru->tanggal_mulai);
|
||||
$endDate = Carbon::parse($kloterTerbaru->tanggal_akhir);
|
||||
} else {
|
||||
$startDate = $endDate = null;
|
||||
}
|
||||
break;
|
||||
case 'hari_ini':
|
||||
$startDate = Carbon::today();
|
||||
$endDate = Carbon::today();
|
||||
break;
|
||||
case 'bulan_ini':
|
||||
$startDate = Carbon::now()->startOfMonth();
|
||||
$endDate = Carbon::now()->endOfMonth();
|
||||
break;
|
||||
case 'semua':
|
||||
$startDate = null;
|
||||
$endDate = null;
|
||||
break;
|
||||
case 'minggu_ini':
|
||||
default:
|
||||
$startDate = Carbon::now()->startOfWeek();
|
||||
$endDate = Carbon::now()->endOfWeek();
|
||||
break;
|
||||
}
|
||||
|
||||
// Ambil semua kloter yang memiliki ton ikan
|
||||
$kloters = Kloter::with(['tonIkan', 'presensis'])
|
||||
->get()
|
||||
->filter(fn($kloter) => $kloter->tonIkan);
|
||||
|
||||
// Hitung gaji per jam tiap kloter
|
||||
// $gajiPerJamKloter = [];
|
||||
|
||||
$gajiPerHariKloter = [];
|
||||
|
||||
foreach ($kloters as $kloter) {
|
||||
$tonIkan = $kloter->tonIkan;
|
||||
$jumlahTon = $tonIkan->jumlah_ton ?? 0;
|
||||
$hargaPerTon = $tonIkan->harga_ikan_per_ton ?? 0;
|
||||
|
||||
$karyawanUnik = Presensi::where('kloter_id', $kloter->id)
|
||||
->distinct('karyawan_id')
|
||||
->pluck('karyawan_id');
|
||||
|
||||
$jumlahPekerjaKloter = $karyawanUnik->count();
|
||||
|
||||
$gajiPerHariKloter[$kloter->id] = $jumlahPekerjaKloter > 0
|
||||
? ($jumlahTon * $hargaPerTon) / $jumlahPekerjaKloter
|
||||
: 0;
|
||||
}
|
||||
|
||||
|
||||
$karyawans = Karyawan::with('presensis.kloter')
|
||||
->when($nama, fn($query) => $query->where('nama', 'like', '%' . $nama . '%'))
|
||||
->get();
|
||||
|
||||
$data = [];
|
||||
|
||||
foreach ($karyawans as $karyawan) {
|
||||
$totalJamKerja = 0;
|
||||
$totalGaji = 0;
|
||||
|
||||
// Ambil semua presensi karyawan, filter sesuai tanggal (misal filter minggu ini/hari ini)
|
||||
$presensis = $karyawan->presensis()
|
||||
->when($startDate && $endDate, fn($query) => $query->whereBetween('tanggal', [$startDate, $endDate]))
|
||||
->with('kloter')
|
||||
->get();
|
||||
|
||||
// Kelompokkan presensi per kloter
|
||||
$presensiPerKloter = $presensis->groupBy('kloter_id');
|
||||
|
||||
$gajiPerKloter = []; // Hitung gaji per kloter
|
||||
|
||||
foreach ($presensiPerKloter as $kloterId => $presensiKloter) {
|
||||
// Hitung total jam kerja karyawan di kloter ini
|
||||
$totalJamKerjaKloter = 0;
|
||||
foreach ($presensiKloter as $presensi) {
|
||||
$jamMasuk = Carbon::parse($presensi->jam_masuk);
|
||||
$jamPulang = Carbon::parse($presensi->jam_pulang);
|
||||
$jamKerja = $jamPulang->diffInSeconds($jamMasuk) / 3600;
|
||||
$totalJamKerjaKloter += $jamKerja;
|
||||
}
|
||||
|
||||
$totalJamKerja += $totalJamKerjaKloter;
|
||||
|
||||
// Gaji per hari kloter (dari hasil sebelumnya)
|
||||
$gajiPerHari = $gajiPerHariKloter[$kloterId] ?? 0; // Variabel ini perlu kamu hitung sebelum loop karyawan
|
||||
|
||||
// Hitung gaji per jam untuk karyawan di kloter ini
|
||||
$gajiPerJam = $totalJamKerjaKloter > 0 ? ($gajiPerHari / $totalJamKerjaKloter) : 0;
|
||||
|
||||
// Hitung gaji kloter ini
|
||||
$gajiKloterIni = $gajiPerJam * $totalJamKerjaKloter;
|
||||
|
||||
// Simpan detail per kloter
|
||||
$gajiPerKloter[] = [
|
||||
'kloter_id' => $kloterId,
|
||||
'total_jam' => round($totalJamKerjaKloter, 2),
|
||||
'gaji' => round($gajiKloterIni, 0),
|
||||
];
|
||||
|
||||
// Tambah total gaji karyawan
|
||||
$totalGaji += $gajiKloterIni;
|
||||
}
|
||||
|
||||
// Potong 20% jika karyawan perempuan
|
||||
if ($karyawan->jenis_kelamin === 'P') {
|
||||
$totalGaji *= 0.8;
|
||||
}
|
||||
|
||||
$data[] = [
|
||||
'karyawan' => $karyawan,
|
||||
'total_jam_kerja' => round($totalJamKerja, 2),
|
||||
'gaji_per_kloter' => $gajiPerKloter,
|
||||
'total_gaji' => round($totalGaji, 0),
|
||||
];
|
||||
}
|
||||
|
||||
if ($request->ajax()) {
|
||||
return view('pimpinan.laporan_karyawan._table', compact('data'));
|
||||
}
|
||||
|
||||
if ($request->has('export') && $request->export === 'excel') {
|
||||
return Excel::download(new LaporanKaryawanExport($data), 'laporan_karyawan.xlsx');
|
||||
}
|
||||
|
||||
return view('pimpinan.laporan_karyawan.index', compact('data', 'filter', 'nama'));
|
||||
}
|
||||
|
||||
public function supplier(Request $request)
|
||||
{
|
||||
$query = Supplier::with(['pemasok', 'konsumen']);
|
||||
|
||||
if ($request->filled('keyword')) {
|
||||
$query->where(function ($q) use ($request) {
|
||||
$q->where('nama', 'like', '%' . $request->keyword . '%')
|
||||
->orWhere('alamat', 'like', '%' . $request->keyword . '%');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if ($request->filled('kategori')) {
|
||||
if ($request->kategori === 'pemasok') {
|
||||
$query->whereHas('pemasok');
|
||||
} elseif ($request->kategori === 'konsumen') {
|
||||
$query->whereHas('konsumen');
|
||||
}
|
||||
}
|
||||
|
||||
$suppliers = $query->get();
|
||||
|
||||
if ($request->has('export') && $request->export === 'excel') {
|
||||
return Excel::download(new LaporanSupplierExport($suppliers), 'laporan_supplier.xlsx');
|
||||
}
|
||||
|
||||
if ($request->ajax()) {
|
||||
return view('pimpinan.laporan_supplier._table', compact('suppliers'))->render();
|
||||
}
|
||||
|
||||
return view('pimpinan.laporan_supplier.index', compact('suppliers'));
|
||||
}
|
||||
|
||||
public function transaksi(Request $request)
|
||||
{
|
||||
$query = Transaksi::with([
|
||||
'barang.produk',
|
||||
'barang.pendukung',
|
||||
'supplier',
|
||||
'pemasukan',
|
||||
'pengeluaran'
|
||||
]);
|
||||
|
||||
if ($request->filled('q')) {
|
||||
$search = $request->q;
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->whereHas('barang', function ($q1) use ($search) {
|
||||
$q1->where('nama_barang', 'like', '%' . $search . '%');
|
||||
})->orWhereHas('supplier', function ($q2) use ($search) {
|
||||
$q2->where('nama', 'like', '%' . $search . '%');
|
||||
})->orWhereHas('barang.produk', function ($q3) use ($search) {
|
||||
$q3->where('kode', 'like', '%' . $search . '%');
|
||||
})->orWhereHas('barang.pendukung', function ($q4) use ($search) {
|
||||
$q4->where('kode', 'like', '%' . $search . '%');
|
||||
})->orWhereHas('pemasukan', function ($q5) use ($search) {
|
||||
$q5->where('kode', 'like', '%' . $search . '%');
|
||||
})->orWhereHas('pengeluaran', function ($q6) use ($search) {
|
||||
$q6->where('kode', 'like', '%' . $search . '%');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Filter tanggal jika ada input
|
||||
if ($request->filled('tanggal_mulai') && $request->filled('tanggal_akhir')) {
|
||||
$query->whereBetween('waktu_transaksi', [
|
||||
$request->tanggal_mulai . ' 00:00:00',
|
||||
$request->tanggal_akhir . ' 23:59:59'
|
||||
]);
|
||||
}
|
||||
|
||||
$transaksis = $query->orderBy('waktu_transaksi')->get();
|
||||
|
||||
$totalSebelumnya = 0;
|
||||
|
||||
$data = $transaksis->map(function ($trx) use (&$totalSebelumnya) {
|
||||
$kodeBarang = $trx->barang->produk->kode ?? $trx->barang->pendukung->kode ?? '-';
|
||||
$masuk = $trx->pemasukan_id ? $trx->jumlahRp : 0;
|
||||
$keluar = $trx->pengeluaran_id ? $trx->jumlahRp : 0;
|
||||
|
||||
$totalSekarang = $totalSebelumnya + $masuk - $keluar;
|
||||
$totalSebelumnya = $totalSekarang;
|
||||
|
||||
return [
|
||||
'waktu' => $trx->waktu_transaksi,
|
||||
'kode_transaksi' => $trx->pemasukan->kode ?? $trx->pengeluaran->kode ?? '-',
|
||||
'kode_barang' => $kodeBarang,
|
||||
'supplier' => $trx->supplier->nama ?? '-',
|
||||
'nama_barang' => $trx->barang->nama_barang ?? '-',
|
||||
'qty' => $trx->qtyHistori ?? 0,
|
||||
'masuk' => $masuk,
|
||||
'keluar' => $keluar,
|
||||
'total' => $totalSekarang,
|
||||
];
|
||||
})->reverse()->values();
|
||||
|
||||
if ($request->has('export')) {
|
||||
if ($request->export === 'excel') {
|
||||
return Excel::download(new LaporanTransaksiExport(
|
||||
$request->tanggal_mulai,
|
||||
$request->tanggal_akhir,
|
||||
$request->q
|
||||
), 'laporan_transaksi.xlsx');
|
||||
}
|
||||
|
||||
if ($request->export === 'pdf') {
|
||||
$daterange = $request->daterange ?? '-';
|
||||
$pdf = PDF::loadView('pimpinan.laporan_transaksi.pdf', compact('data', 'daterange'))
|
||||
->setPaper('A4', 'landscape');
|
||||
return $pdf->download('laporan_transaksi.pdf');
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->ajax()) {
|
||||
return view('pimpinan.laporan_transaksi._table', compact('data'));
|
||||
}
|
||||
|
||||
return view('pimpinan.laporan_transaksi.index', compact('data'));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
<?php
|
||||
// app/Http/Controllers/PresensiController.php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Kloter;
|
||||
use App\Models\Karyawan;
|
||||
use App\Models\Presensi;
|
||||
use App\Models\TonIkan;
|
||||
use App\Models\KloterKaryawan;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class PresensiController extends Controller
|
||||
{
|
||||
public function index(Request $request, $kloter_id = null)
|
||||
{
|
||||
$tanggal = now()->toDateString();
|
||||
$kloters = Kloter::orderBy('id', 'desc')->get();
|
||||
|
||||
// Tombol buat kloter baru
|
||||
if ($request->get('buat_kloter')) {
|
||||
$selectedKloter = Kloter::create([
|
||||
'nama_kloter' => 'Kloter-' . (Kloter::count() + 1)
|
||||
]);
|
||||
return redirect()->route('presensi.index', ['kloter_id' => $selectedKloter->id]);
|
||||
}
|
||||
|
||||
// Tombol pilih kloter
|
||||
$selectedKloter = $kloter_id
|
||||
? Kloter::with('tonIkan')->find($kloter_id)
|
||||
: Kloter::latest()->first();
|
||||
|
||||
if (!$selectedKloter) {
|
||||
$selectedKloter = Kloter::create([
|
||||
'nama_kloter' => 'Kloter-' . (Kloter::count() + 1)
|
||||
]);
|
||||
}
|
||||
|
||||
$semuaKaryawan = Karyawan::all();
|
||||
|
||||
$karyawanIds = KloterKaryawan::where('kloter_id', $selectedKloter->id)
|
||||
->pluck('karyawan_id');
|
||||
|
||||
$karyawans = Karyawan::whereIn('id', $karyawanIds)->get();
|
||||
|
||||
$presensis = Presensi::where('kloter_id', $selectedKloter->id)
|
||||
->whereDate('tanggal', $tanggal)
|
||||
->get()
|
||||
->keyBy('karyawan_id');
|
||||
|
||||
$jumlahTonHariIni = TonIkan::where('kloter_id', $selectedKloter->id)
|
||||
->value('jumlah_ton') ?? 0;
|
||||
|
||||
$hargaIkanPerTon = TonIkan::where('kloter_id', $selectedKloter->id)
|
||||
->value('harga_ikan_per_ton') ?? 1000000;
|
||||
|
||||
return view('operator.presensi.index',
|
||||
compact('karyawans', 'presensis', 'tanggal', 'kloters', 'selectedKloter', 'jumlahTonHariIni', 'hargaIkanPerTon', 'semuaKaryawan')
|
||||
);
|
||||
}
|
||||
|
||||
public function inputMasuk(Request $request, $id)
|
||||
{
|
||||
$kloterId = $request->input('kloter_id');
|
||||
$tanggal = now()->toDateString();
|
||||
$jamInput = $request->input('jam') ?? Carbon::now()->format('H:i:s'); // <- ambil jam dari request jika ada
|
||||
|
||||
// Validasi: jam tidak boleh lebih dari waktu sekarang
|
||||
$sekarang = now()->format('H:i:s');
|
||||
if ($jamInput > $sekarang) {
|
||||
return redirect()->back()->with('error', 'Jam masuk tidak boleh lebih dari waktu saat ini.');
|
||||
}
|
||||
|
||||
$presensi = Presensi::where('karyawan_id', $id)
|
||||
->whereDate('tanggal', $tanggal)
|
||||
->first();
|
||||
|
||||
if (!$presensi) {
|
||||
$presensi = Presensi::create([
|
||||
'karyawan_id' => $id,
|
||||
'kloter_id' => $kloterId,
|
||||
'tanggal' => $tanggal,
|
||||
'jam_masuk' => $jamInput
|
||||
]);
|
||||
} elseif (!$presensi->jam_masuk) {
|
||||
$presensi->jam_masuk = $jamInput;
|
||||
$presensi->kloter_id = $kloterId;
|
||||
$presensi->save();
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success', 'Jam masuk berhasil disimpan.');
|
||||
}
|
||||
|
||||
public function inputPulang(Request $request, $id)
|
||||
{
|
||||
$kloterId = $request->input('kloter_id');
|
||||
$tanggal = now()->toDateString();
|
||||
$jamInput = $request->input('jam') ?? Carbon::now()->format('H:i:s');
|
||||
|
||||
// Validasi: jam tidak boleh lebih dari waktu sekarang
|
||||
$sekarang = now()->format('H:i:s');
|
||||
if ($jamInput > $sekarang) {
|
||||
return redirect()->back()->with('error', 'Jam pulang tidak boleh lebih dari waktu saat ini.');
|
||||
}
|
||||
|
||||
$presensi = Presensi::where('karyawan_id', $id)
|
||||
->whereDate('tanggal', $tanggal)
|
||||
->first();
|
||||
|
||||
if ($presensi && !$presensi->jam_pulang) {
|
||||
$presensi->jam_pulang = $jamInput;
|
||||
$presensi->kloter_id = $kloterId;
|
||||
$presensi->save();
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success', 'Jam pulang berhasil disimpan.');
|
||||
}
|
||||
|
||||
public function simpanTonIkan(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'kloter_id' => 'required|exists:kloters,id',
|
||||
'jumlah_ton' => 'required|numeric',
|
||||
'harga_ikan_per_ton' => 'required|numeric',
|
||||
]);
|
||||
|
||||
TonIkan::updateOrCreate(
|
||||
['kloter_id' => $request->kloter_id/*, 'tanggal' => $request->tanggal*/],
|
||||
[
|
||||
'jumlah_ton' => $request->jumlah_ton ?? 0,
|
||||
'harga_ikan_per_ton' => $request->harga_ikan_per_ton
|
||||
],
|
||||
);
|
||||
|
||||
return redirect()->back()->with('success', 'Data ton ikan berhasil disimpan.');
|
||||
}
|
||||
|
||||
public function pilihKaryawan(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'kloter_id' => 'required|exists:kloters,id',
|
||||
'karyawan_ids' => 'array'
|
||||
]);
|
||||
|
||||
// Hapus dulu data lama
|
||||
KloterKaryawan::where('kloter_id', $request->kloter_id)->delete();
|
||||
|
||||
// Simpan baru
|
||||
foreach ($request->karyawan_ids ?? [] as $id) {
|
||||
KloterKaryawan::create([
|
||||
'kloter_id' => $request->kloter_id,
|
||||
'karyawan_id' => $id
|
||||
]);
|
||||
}
|
||||
|
||||
return redirect()->route('presensi.index', ['kloter_id' => $request->kloter_id])
|
||||
->with('success', 'Karyawan berhasil dipilih untuk kloter ini.');
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,154 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Supplier;
|
||||
use App\Models\Pemasok;
|
||||
use App\Models\Konsumen;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SupplierController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$keyword = $request->query('keyword');
|
||||
$kategori = $request->query('kategori');
|
||||
|
||||
$suppliers = Supplier::with(['pemasok', 'konsumen']);
|
||||
|
||||
// filter berdasarkan keyword
|
||||
if ($keyword) {
|
||||
$suppliers = $suppliers->where(function ($query) use ($keyword) {
|
||||
$query->where('nama', 'like', '%' . $keyword . '%')
|
||||
->orWhere('alamat', 'like', '%' . $keyword . '%');
|
||||
});
|
||||
}
|
||||
|
||||
// Filter berdasarkan kategori mitra
|
||||
if ($kategori === 'pemasok') {
|
||||
$suppliers = $suppliers->whereHas('pemasok');
|
||||
} elseif ($kategori === 'konsumen') {
|
||||
$suppliers = $suppliers->whereHas('konsumen');
|
||||
}
|
||||
|
||||
$suppliers = $suppliers->get();
|
||||
|
||||
return view('operator.supplier.index', compact('suppliers'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$pemasoks = Pemasok::all();
|
||||
$konsumens = Konsumen::all();
|
||||
|
||||
return view('operator.supplier.create', compact('pemasoks', 'konsumens'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'kategori' => 'required|in:pemasok,konsumen',
|
||||
'nama' => 'required|string|max:255',
|
||||
'alamat' => 'required|string|max:255',
|
||||
'no_tlp' => 'required|string|max:15',
|
||||
'no_rekening' => 'nullable|string|max:50',
|
||||
]);
|
||||
|
||||
// 1. Buat supplier dulu
|
||||
$supplier = Supplier::create([
|
||||
'nama' => $request->nama,
|
||||
'alamat' => $request->alamat,
|
||||
'no_tlp' => $request->no_tlp,
|
||||
'no_rekening' => $request->no_rekening,
|
||||
]);
|
||||
|
||||
// 2. Buat entri di pemasoks / konsumens tergantung kategori
|
||||
$kode = $this->generateKode($request->kategori);
|
||||
|
||||
if ($request->kategori === 'pemasok') {
|
||||
Pemasok::create([
|
||||
'kode' => $kode,
|
||||
'supplier_id' => $supplier->id,
|
||||
]);
|
||||
} else {
|
||||
Konsumen::create([
|
||||
'kode' => $kode,
|
||||
'supplier_id' => $supplier->id,
|
||||
]);
|
||||
}
|
||||
|
||||
return redirect()->route('supplier.index')->with('success', 'Supplier berhasil ditambahkan.');
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$request->validate([
|
||||
'kategori' => 'required|in:pemasok,konsumen',
|
||||
'nama' => 'required|string|max:255',
|
||||
'alamat' => 'required|string|max:255',
|
||||
'no_tlp' => 'required|string|max:15',
|
||||
'no_rekening' => 'nullable|string|max:50',
|
||||
]);
|
||||
|
||||
$supplier = Supplier::with(['pemasok', 'konsumen'])->findOrFail($id);
|
||||
|
||||
// Update data utama
|
||||
$supplier->update([
|
||||
'nama' => $request->nama,
|
||||
'alamat' => $request->alamat,
|
||||
'no_tlp' => $request->no_tlp,
|
||||
'no_rekening' => $request->no_rekening,
|
||||
]);
|
||||
|
||||
$kategori_lama = $supplier->pemasok ? 'pemasok' : ($supplier->konsumen ? 'konsumen' : null);
|
||||
$kategori_baru = $request->kategori;
|
||||
|
||||
// Jika kategori berubah, hapus relasi lama dan buat yang baru
|
||||
if ($kategori_lama !== $kategori_baru) {
|
||||
if ($kategori_lama === 'pemasok') {
|
||||
$supplier->pemasok->delete();
|
||||
} elseif ($kategori_lama === 'konsumen') {
|
||||
$supplier->konsumen->delete();
|
||||
}
|
||||
|
||||
$kodeBaru = $this->generateKode($kategori_baru);
|
||||
|
||||
if ($kategori_baru === 'pemasok') {
|
||||
Pemasok::create([
|
||||
'supplier_id' => $supplier->id,
|
||||
'kode' => $kodeBaru,
|
||||
]);
|
||||
} elseif ($kategori_baru === 'konsumen') {
|
||||
Konsumen::create([
|
||||
'supplier_id' => $supplier->id,
|
||||
'kode' => $kodeBaru,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->route('supplier.index')->with('success', 'Supplier berhasil diperbarui.');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$supplier = Supplier::findOrFail($id);
|
||||
$supplier->delete();
|
||||
|
||||
return redirect()->route('supplier.index')->with('success', 'Supplier berhasil dihapus.');
|
||||
}
|
||||
|
||||
private function generateKode($kategori)
|
||||
{
|
||||
$prefix = $kategori === 'pemasok' ? 'PMK' : 'KSM';
|
||||
$model = $kategori === 'pemasok' ? Pemasok::class : Konsumen::class;
|
||||
|
||||
$last = $model::orderBy('id', 'desc')->first();
|
||||
$lastNumber = $last ? (int)substr($last->kode, 3) : 0;
|
||||
|
||||
return $prefix . str_pad($lastNumber + 1, 3, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Models\TonIkan;
|
||||
|
||||
class TonIkanController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'tanggal' => 'required|date',
|
||||
'jumlah_ton' => 'required|numeric|min:0',
|
||||
'harga_ikan_per_ton' => 'required|numeric|min:0',
|
||||
]);
|
||||
|
||||
TonIkan::updateOrCreate(
|
||||
['tanggal' => $request->tanggal],
|
||||
['jumlah_ton' => $request->jumlah_ton],
|
||||
['harga_ikan_per_ton' => $request->harga_ikan_per_ton]
|
||||
);
|
||||
|
||||
return redirect()->back()->with('success', 'Jumlah ton ikan berhasil disimpan.');
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,367 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Models\Transaksi;
|
||||
use App\Models\Barang;
|
||||
use App\Models\BarangProduk;
|
||||
use App\Models\BarangPendukung;
|
||||
use App\Models\Supplier;
|
||||
use App\Models\Pemasukan;
|
||||
use App\Models\Pengeluaran;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Exports\LaporanTransaksiExport;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class TransaksiController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$query = Transaksi::with([
|
||||
'barang.produk',
|
||||
'barang.pendukung',
|
||||
'supplier',
|
||||
'pemasukan',
|
||||
'pengeluaran',
|
||||
'historyGajiKloter',
|
||||
]);
|
||||
|
||||
// filter tanggal jika diisi
|
||||
if ($request->filled('tanggal_mulai') && $request->filled('tanggal_akhir')) {
|
||||
$query->whereBetween('waktu_transaksi', [
|
||||
$request->tanggal_mulai . ' 00:00:00',
|
||||
$request->tanggal_akhir . ' 23:59:59'
|
||||
]);
|
||||
// lanjutkan kebawah nya jika ingin menganti default dengan bulan ini
|
||||
// } else {
|
||||
// // Default: bulan ini
|
||||
// $query->whereBetween('waktu_transaksi', [
|
||||
// now()->startOfMonth(),
|
||||
// now()->endOfMonth()
|
||||
// ]);
|
||||
}
|
||||
|
||||
$transaksis = $query->orderBy('waktu_transaksi')->get(); // Di urut dari terlama ke terbaru
|
||||
// $transaksis = $query->latest('waktu_transaksi')->get(); // Di urut dari terbaru ke terlama
|
||||
|
||||
$totalSebelumnya = 0;
|
||||
|
||||
$data = $transaksis->map(function ($trx) use (&$totalSebelumnya) {
|
||||
$kodeBarang = $trx->barang->produk->kode ?? $trx->barang->pendukung->kode ?? '-';
|
||||
$masuk = $trx->pemasukan_id ? $trx->jumlahRp : 0;
|
||||
$keluar = $trx->pengeluaran_id ? $trx->jumlahRp : 0;
|
||||
|
||||
$totalSekarang = $totalSebelumnya + $masuk - $keluar;
|
||||
$totalSebelumnya = $totalSekarang;
|
||||
|
||||
// Jika transaksi berasal dari history gaji kloter
|
||||
$namaTransaksi = $trx->historyGajiKloter
|
||||
? 'Pembayaran Gaji Kloter #' . $trx->historyGajiKloter->id
|
||||
: ($trx->barang->nama_barang ?? '-');
|
||||
|
||||
return [
|
||||
'id' => $trx->id,
|
||||
'barang_id' => $trx->barang_id,
|
||||
// 'transaksi_id' => $trx->id,
|
||||
'supplier_id' => $trx->supplier_id,
|
||||
'pemasukan_id' => $trx->pemasukan_id,
|
||||
'pengeluaran_id' => $trx->pengeluaran_id,
|
||||
'kategori' => $trx->kategori,
|
||||
'waktu' => $trx->waktu_transaksi,
|
||||
'kode_transaksi' => $trx->pemasukan->kode ?? $trx->pengeluaran->kode ?? '-',
|
||||
'kode_barang' => $kodeBarang,
|
||||
'supplier' => $trx->supplier->nama ?? '-',
|
||||
'barangs' => $namaTransaksi,
|
||||
'nama_barang' => $namaTransaksi,
|
||||
'qty' => $trx->qtyHistori ?? 0, // akan mengambil dari qtyHistori pada tb transaksi
|
||||
'masuk' => $masuk,
|
||||
'keluar' => $keluar,
|
||||
'total' => $totalSekarang,
|
||||
'jumlahRp' => $trx->jumlahRp,
|
||||
'satuan' => $trx->satuan,
|
||||
'waktu_transaksi' => $trx->waktu_transaksi,
|
||||
];
|
||||
})->reverse()->values(); //akan membalik urutan perhitungan total data transaksi
|
||||
|
||||
// kategori dan tipe barang
|
||||
$kategori = $request->input('kategori', 'pengeluaran'); // default ke pemasukan
|
||||
$tipe = $kategori === 'pengeluaran' ? 'pendukung' : 'produk'; // otomatis
|
||||
// $barangs = Barang::with($tipe)->whereHas($tipe)->get(); // ambil semua barang sesuai tipe
|
||||
$barangs = Barang::with(['produk', 'pendukung'])->get()->map(function ($b) {
|
||||
// Tentukan tipe berdasarkan relasi yang ada
|
||||
if ($b->produk) {
|
||||
$b->tipe = 'produk';
|
||||
} elseif ($b->pendukung) {
|
||||
$b->tipe = 'pendukung';
|
||||
} else {
|
||||
$b->tipe = null;
|
||||
}
|
||||
return $b;
|
||||
});
|
||||
$suppliers = Supplier::with(['pemasok', 'konsumen'])->get(); // ambil semua supplier
|
||||
$pemasoks = Supplier::whereHas('pemasok')->get();
|
||||
$konsumens = Supplier::whereHas('konsumen')->get();
|
||||
|
||||
$kardusList = Barang::with('kardus')->get()->flatMap(function ($barang) {
|
||||
return $barang->kardus;
|
||||
});
|
||||
|
||||
|
||||
// dd($kategori, $tipe, $barangs->pluck('nama_barang')); // debug untuk melihat kategori, tipe, dan nama barang
|
||||
|
||||
return view('operator.transaksi.index', [
|
||||
'data' => $data,
|
||||
'barangs' => $barangs,
|
||||
'suppliers' => $suppliers,
|
||||
'pemasoks' => $pemasoks,
|
||||
'konsumens' => $konsumens,
|
||||
'kardusList' => $kardusList,
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'kategori' => 'required|in:pemasukan,pengeluaran',
|
||||
'barang_id' => 'required|exists:barangs,id',
|
||||
'supplier_id' => 'required|exists:suppliers,id',
|
||||
'qtyHistori' => 'required|numeric|min:1',
|
||||
'jumlahRp' => 'nullable|numeric|min:0',
|
||||
'satuan' => 'required|in:ton,kg,g,liter,paket',
|
||||
'jenis_kardus' => 'nullable|exists:barangs,id',
|
||||
'jumlah_kardus' => 'nullable|numeric|min:0',
|
||||
]);
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$barang = Barang::findOrFail($request->barang_id);
|
||||
$kategori = $request->kategori;
|
||||
$qtyHistori = $request->qtyHistori;
|
||||
$jumlahRp = $request->jumlahRp;
|
||||
$satuan = $request->satuan;
|
||||
$waktu = Carbon::now();
|
||||
|
||||
// Konversi satuan ke KG
|
||||
$qty_kg = match($satuan) {
|
||||
'ton' => $qtyHistori * 1000,
|
||||
'kg' => $qtyHistori,
|
||||
'g' => $qtyHistori / 1000,
|
||||
default => $qtyHistori // liter dan paket tidak dikonversi
|
||||
};
|
||||
|
||||
$hargaKardus = 0;
|
||||
if ($request->filled('jenis_kardus') && $request->jumlah_kardus > 0) {
|
||||
$kardus = Barang::find($request->jenis_kardus);
|
||||
if ($kardus) {
|
||||
$hargaKardus = $kardus->harga * $request->jumlah_kardus;
|
||||
|
||||
// Kurangi stok kardus
|
||||
$kardus->qty -= $request->jumlah_kardus;
|
||||
$kardus->save();
|
||||
}
|
||||
}
|
||||
|
||||
// Variabel untuk ID
|
||||
$pemasukan_id = null;
|
||||
$pengeluaran_id = null;
|
||||
|
||||
if ($kategori === 'pemasukan') {
|
||||
// Buat kode pemasukan
|
||||
$last = Pemasukan::latest('id')->first();
|
||||
$nextNumber = $last ? $last->id + 1 : 1;
|
||||
$kode = 'MSK' . str_pad($nextNumber, 3, '0', STR_PAD_LEFT);
|
||||
$pemasukan = Pemasukan::create(['kode' => $kode]);
|
||||
$pemasukan_id = $pemasukan->id;
|
||||
|
||||
// Barang dikurangi
|
||||
$barang->qty -= $qty_kg;
|
||||
$barang->save();
|
||||
|
||||
// Cek stok cukup
|
||||
if ($barang->qty < $qty_kg) {
|
||||
return back()->withInput()->withErrors(['qtyHistori' => 'Stok barang tidak mencukupi.']);
|
||||
}
|
||||
|
||||
// Hitung jumlahRp jika kosong
|
||||
$jumlahRp = $jumlahRp ?: ($barang->harga * $qty_kg);
|
||||
$jumlahRp += $hargaKardus;
|
||||
|
||||
} elseif ($kategori === 'pengeluaran') {
|
||||
// Buat kode pengeluaran
|
||||
$last = Pengeluaran::latest('id')->first();
|
||||
$nextNumber = $last ? $last->id + 1 : 1;
|
||||
$kode = 'KLR' . str_pad($nextNumber, 3, '0', STR_PAD_LEFT);
|
||||
$pengeluaran = Pengeluaran::create(['kode' => $kode]);
|
||||
$pengeluaran_id = $pengeluaran->id;
|
||||
|
||||
// Barang dikurangi
|
||||
$barang->qty += $qty_kg;
|
||||
$barang->save();
|
||||
|
||||
// if ($jumlahRp && $qty_kg > 0) {
|
||||
// $barang->harga = $jumlahRp / $qty_kg;
|
||||
// $barang->save();
|
||||
// }
|
||||
|
||||
if ($jumlahRp && $qty_kg > 0) {
|
||||
$hargaBarangSaja = $jumlahRp - $hargaKardus;
|
||||
|
||||
if ($hargaBarangSaja > 0) {
|
||||
$barang->harga = $hargaBarangSaja / $qty_kg;
|
||||
$barang->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Simpan transaksi
|
||||
Transaksi::create([
|
||||
'kategori' => $kategori,
|
||||
'barang_id' => $barang->id,
|
||||
'supplier_id' => $request->supplier_id,
|
||||
'pemasukan_id' => $pemasukan_id,
|
||||
'pengeluaran_id' => $pengeluaran_id,
|
||||
'qtyHistori' => $qty_kg,
|
||||
'jumlahRp' => $jumlahRp,
|
||||
'satuan' => $satuan,
|
||||
'waktu_transaksi' => $waktu,
|
||||
'keterangan' => json_encode([
|
||||
'jenis_kardus_id' => $request->jenis_kardus,
|
||||
'jumlah_kardus' => $request->jumlah_kardus,
|
||||
]),
|
||||
]);
|
||||
|
||||
DB::commit();
|
||||
return redirect()->route('operator.transaksi.index')->with('success', 'Transaksi berhasil disimpan.');
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
DB::rollBack();
|
||||
return back()->withInput()->withErrors(['error' => 'Gagal menyimpan transaksi: ' . $th->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$request->validate([
|
||||
'kategori' => 'required|in:pemasukan,pengeluaran',
|
||||
'barang_id' => 'required|exists:barangs,id',
|
||||
'supplier_id' => 'required|exists:suppliers,id',
|
||||
'qtyHistori' => 'required|numeric|min:1',
|
||||
'jumlahRp' => 'nullable|numeric|min:0',
|
||||
'waktu_transaksi' => 'nullable|date',
|
||||
'satuan' => 'required|in:ton,kg,g,liter,paket',
|
||||
'jenis_kardus' => 'nullable|exists:barangs,id',
|
||||
'jumlah_kardus' => 'nullable|numeric|min:0',
|
||||
]);
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$transaksi = Transaksi::findOrFail($id);
|
||||
$barang = Barang::findOrFail($request->barang_id);
|
||||
|
||||
// Kembalikan stok barang sebelumnya
|
||||
if ($transaksi->kategori === 'pengeluaran') {
|
||||
$barang->qty -= $transaksi->qtyHistori;
|
||||
} else {
|
||||
$barang->qty += $transaksi->qtyHistori;
|
||||
}
|
||||
|
||||
// Ambil data kardus lama dari keterangan dan kembalikan stok
|
||||
$keteranganLama = json_decode($transaksi->keterangan, true) ?? [];
|
||||
$jenisKardusLamaId = $keteranganLama['jenis_kardus_id'] ?? null;
|
||||
$jumlahKardusLama = $keteranganLama['jumlah_kardus'] ?? 0;
|
||||
|
||||
if ($jenisKardusLamaId && $jumlahKardusLama > 0) {
|
||||
Barang::where('id', $jenisKardusLamaId)->increment('qty', $jumlahKardusLama);
|
||||
}
|
||||
|
||||
// Hitung qty dalam kg
|
||||
$qty = $request->qtyHistori;
|
||||
$satuan = $request->satuan;
|
||||
$qty_kg = match($satuan) {
|
||||
'ton' => $qty * 1000,
|
||||
'kg' => $qty,
|
||||
'g' => $qty / 1000,
|
||||
default => $qty,
|
||||
};
|
||||
|
||||
// Hitung harga kardus baru
|
||||
$hargaKardus = 0;
|
||||
if ($request->filled('jenis_kardus') && $request->jumlah_kardus > 0) {
|
||||
$kardusBaru = Barang::find($request->jenis_kardus);
|
||||
if ($kardusBaru) {
|
||||
$hargaKardus = $kardusBaru->harga * $request->jumlah_kardus;
|
||||
$kardusBaru->qty -= $request->jumlah_kardus;
|
||||
$kardusBaru->save();
|
||||
}
|
||||
}
|
||||
|
||||
// Hitung ulang stok & harga barang
|
||||
if ($request->kategori === 'pengeluaran') {
|
||||
$barang->qty += $qty_kg;
|
||||
} else {
|
||||
if ($barang->qty < $qty_kg) {
|
||||
return back()->withErrors(['qtyHistori' => 'Stok barang tidak mencukupi untuk pemasukan.']);
|
||||
}
|
||||
$barang->qty -= $qty_kg;
|
||||
|
||||
// Hitung harga barang (tidak termasuk kardus)
|
||||
if ($request->jumlahRp && $qty_kg > 0) {
|
||||
$hargaBarangSaja = $request->jumlahRp - $hargaKardus;
|
||||
if ($hargaBarangSaja > 0) {
|
||||
$barang->harga = $hargaBarangSaja / $qty_kg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$barang->save();
|
||||
|
||||
// Hitung total jumlah Rp termasuk kardus
|
||||
$jumlahRp = $request->jumlahRp ?: ($barang->harga * $qty_kg);
|
||||
$jumlahRp += $hargaKardus;
|
||||
|
||||
// Simpan perubahan transaksi
|
||||
$transaksi->update([
|
||||
'barang_id' => $barang->id,
|
||||
'supplier_id' => $request->supplier_id,
|
||||
'kategori' => $request->kategori,
|
||||
'jumlahRp' => $jumlahRp,
|
||||
'qtyHistori' => $qty,
|
||||
'satuan' => $satuan,
|
||||
'waktu_transaksi' => $request->waktu_transaksi,
|
||||
'keterangan' => json_encode([
|
||||
'jenis_kardus_id' => $request->jenis_kardus,
|
||||
'jumlah_kardus' => $request->jumlah_kardus,
|
||||
])
|
||||
]);
|
||||
|
||||
DB::commit();
|
||||
return redirect()->route('operator.transaksi.index')->with('success', 'Transaksi berhasil diperbarui.');
|
||||
} catch (\Throwable $th) {
|
||||
DB::rollBack();
|
||||
return back()->withInput()->withErrors(['error' => 'Gagal memperbarui transaksi: ' . $th->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$transaksi = Transaksi::findOrFail($id);
|
||||
$transaksi->delete();
|
||||
|
||||
return redirect()->route('operator.transaksi.index')->with('success', 'Data transaksi berhasil dihapus.');
|
||||
}
|
||||
|
||||
public function exportExcel(Request $request)
|
||||
{
|
||||
$tanggalMulai = $request->tanggal_mulai;
|
||||
$tanggalAkhir = $request->tanggal_akhir;
|
||||
$q = $request->q; // Optional, untuk pencarian
|
||||
|
||||
$filename = 'laporan_transaksi_operator_' . now()->format('Ymd_His') . '.xlsx';
|
||||
return Excel::download(new LaporanTransaksiExport($tanggalMulai, $tanggalAkhir, $q), $filename);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array<int, class-string|string>
|
||||
*/
|
||||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Illuminate\Http\Middleware\HandleCors::class,
|
||||
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array<string, array<int, class-string|string>>
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
\Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's middleware aliases.
|
||||
*
|
||||
* Aliases may be used instead of class names to conveniently assign middleware to routes and groups.
|
||||
*
|
||||
* @var array<string, class-string|string>
|
||||
*/
|
||||
protected $middlewareAliases = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||
'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class,
|
||||
'signed' => \App\Http\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
'role' => \App\Http\Middleware\CheckRole::class,
|
||||
];
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class Authenticate extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*/
|
||||
protected function redirectTo(Request $request): ?string
|
||||
{
|
||||
return $request->expectsJson() ? null : route('login');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class CheckRole
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
|
||||
public function handle(Request $request, Closure $next, $role)
|
||||
{
|
||||
if (Auth::check() && Auth::user()->role === $role) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
return redirect('/')->with('error', 'Anda tidak memiliki akses!');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
|
||||
|
||||
class PreventRequestsDuringMaintenance extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, string ...$guards): Response
|
||||
{
|
||||
$guards = empty($guards) ? [null] : $guards;
|
||||
|
||||
foreach ($guards as $guard) {
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
||||
|
||||
class TrustHosts extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the host patterns that should be trusted.
|
||||
*
|
||||
* @return array<int, string|null>
|
||||
*/
|
||||
public function hosts(): array
|
||||
{
|
||||
return [
|
||||
$this->allSubdomainsOfApplicationUrl(),
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array<int, string>|string|null
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
/**
|
||||
* The headers that should be used to detect proxies.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $headers =
|
||||
Request::HEADER_X_FORWARDED_FOR |
|
||||
Request::HEADER_X_FORWARDED_HOST |
|
||||
Request::HEADER_X_FORWARDED_PORT |
|
||||
Request::HEADER_X_FORWARDED_PROTO |
|
||||
Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
|
||||
|
||||
class ValidateSignature extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the query string parameters that should be ignored.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
// 'fbclid',
|
||||
// 'utm_campaign',
|
||||
// 'utm_content',
|
||||
// 'utm_medium',
|
||||
// 'utm_source',
|
||||
// 'utm_term',
|
||||
];
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Barang extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'nama_barang',
|
||||
'qty',
|
||||
'exp',
|
||||
'harga',
|
||||
];
|
||||
|
||||
public function produk()
|
||||
{
|
||||
return $this->hasOne(BarangProduk::class);
|
||||
}
|
||||
|
||||
public function pendukung()
|
||||
{
|
||||
return $this->hasOne(BarangPendukung::class);
|
||||
}
|
||||
|
||||
public function transaksis()
|
||||
{
|
||||
return $this->hasMany(Transaksi::class);
|
||||
}
|
||||
|
||||
public function kardus()
|
||||
{
|
||||
return $this->hasMany(BarangPendukung::class)->whereHas('barang', function ($query) {
|
||||
$query->where('nama_barang', 'like', '%kardus%');
|
||||
});
|
||||
}
|
||||
|
||||
public static function uangMakanHarian()
|
||||
{
|
||||
return self::where('nama_barang', 'like', '%makan%')->first();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BarangPendukung extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'barang_id',
|
||||
'kode',
|
||||
];
|
||||
|
||||
public function barang()
|
||||
{
|
||||
return $this->belongsTo(Barang::class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BarangProduk extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'barang_id',
|
||||
'kode',
|
||||
];
|
||||
|
||||
public function barang()
|
||||
{
|
||||
return $this->belongsTo(Barang::class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
// app/Models/HistoryGajiKloter.php
|
||||
class HistoryGajiKloter extends Model
|
||||
{
|
||||
// protected $table = 'history_gaji_kloter';
|
||||
|
||||
protected $fillable = [
|
||||
'kloter_id',
|
||||
'kode',
|
||||
'jml_karyawan',
|
||||
'total_gaji',
|
||||
'waktu',
|
||||
'tanggal_awal',
|
||||
'tanggal_akhir',
|
||||
];
|
||||
|
||||
public static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($model) {
|
||||
// Jika kode belum diset secara manual
|
||||
if (empty($model->kode)) {
|
||||
$last = self::orderBy('id', 'desc')->first();
|
||||
$nextId = $last ? $last->id + 1 : 1;
|
||||
$model->kode = 'PGJ' . str_pad($nextId, 3, '0', STR_PAD_LEFT);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function kloter()
|
||||
{
|
||||
return $this->belongsTo(Kloter::class);
|
||||
}
|
||||
|
||||
public function pengeluaranGaji()
|
||||
{
|
||||
return $this->hasOne(PengeluaranGaji::class);
|
||||
}
|
||||
|
||||
public function transaksis()
|
||||
{
|
||||
return $this->hasMany(Transaksi::class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
// app/Models/Karyawan.php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Karyawan extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'nama',
|
||||
'jenis_kelamin',
|
||||
'no_telepon',
|
||||
];
|
||||
|
||||
public function presensis()
|
||||
{
|
||||
return $this->hasMany(Presensi::class);
|
||||
}
|
||||
|
||||
public function kloterKaryawans()
|
||||
{
|
||||
return $this->hasMany(KloterKaryawan::class);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Kloter extends Model
|
||||
{
|
||||
protected $fillable = ['nama_kloter'];
|
||||
|
||||
public function presensis()
|
||||
{
|
||||
return $this->hasMany(Presensi::class);
|
||||
}
|
||||
|
||||
public function tonIkan()
|
||||
{
|
||||
return $this->hasOne(TonIkan::class);
|
||||
}
|
||||
|
||||
public function kloterKaryawans()
|
||||
{
|
||||
return $this->hasMany(KloterKaryawan::class);
|
||||
}
|
||||
|
||||
public function getTanggalMulaiAttribute()
|
||||
{
|
||||
return $this->presensis()->orderBy('tanggal', 'asc')->value('tanggal');
|
||||
}
|
||||
|
||||
public function getTanggalAkhirAttribute()
|
||||
{
|
||||
return $this->presensis()->orderBy('tanggal', 'desc')->value('tanggal');
|
||||
}
|
||||
|
||||
public function getJumlahTonAttribute()
|
||||
{
|
||||
return $this->tonIkan()->value('jumlah_ton') ?? 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class KloterKaryawan extends Model
|
||||
{
|
||||
protected $fillable = ['kloter_id', 'karyawan_id'];
|
||||
|
||||
public function kloter()
|
||||
{
|
||||
return $this->belongsTo(Kloter::class);
|
||||
}
|
||||
|
||||
public function karyawan()
|
||||
{
|
||||
return $this->belongsTo(Karyawan::class);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Konsumen extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['supplier_id', 'kode'];
|
||||
|
||||
public function supplier()
|
||||
{
|
||||
return $this->belongsTo(Supplier::class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Pemasok extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['supplier_id', 'kode'];
|
||||
|
||||
public function supplier()
|
||||
{
|
||||
return $this->belongsTo(Supplier::class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Pemasukan extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['kode'];
|
||||
|
||||
public function transaksis()
|
||||
{
|
||||
return $this->hasMany(Transaksi::class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Pengeluaran extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['kode'];
|
||||
|
||||
public function transaksis()
|
||||
{
|
||||
return $this->hasMany(Transaksi::class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
// app/Models/Presensi.php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Presensi extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'karyawan_id',
|
||||
'kloter_id',
|
||||
'tanggal',
|
||||
'jam_masuk',
|
||||
'jam_pulang',
|
||||
];
|
||||
|
||||
public function karyawan()
|
||||
{
|
||||
return $this->belongsTo(Karyawan::class);
|
||||
}
|
||||
|
||||
public function kloter()
|
||||
{
|
||||
return $this->belongsTo(Kloter::class);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Supplier extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable =
|
||||
[
|
||||
'nama',
|
||||
'alamat',
|
||||
'no_tlp',
|
||||
'no_rekening',
|
||||
];
|
||||
|
||||
public function pemasok()
|
||||
{
|
||||
return $this->hasOne(Pemasok::class);
|
||||
}
|
||||
|
||||
public function konsumen()
|
||||
{
|
||||
return $this->hasOne(Konsumen::class);
|
||||
}
|
||||
|
||||
public function transaksis()
|
||||
{
|
||||
return $this->hasMany(Transaksi::class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
// app/Models/TonIkan.php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TonIkan extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
// 'tanggal',
|
||||
'kloter_id',
|
||||
'jumlah_ton',
|
||||
'harga_ikan_per_ton'
|
||||
];
|
||||
|
||||
public function kloter()
|
||||
{
|
||||
return $this->belongsTo(Kloter::class);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Transaksi extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'barang_id',
|
||||
'supplier_id',
|
||||
'pengeluaran_id',
|
||||
'pemasukan_id',
|
||||
'history_gaji_kloter_id',
|
||||
'qtyHistori',
|
||||
'satuan',
|
||||
'jumlahRp',
|
||||
'waktu_transaksi',
|
||||
];
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
static::creating(function ($transaksi) {
|
||||
if (!($transaksi->pemasukan_id xor $transaksi->pengeluaran_id)) {
|
||||
throw new \Exception('Transaksi harus punya salah satu: pemasukan atau pengeluaran.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function getKategoriAttribute()
|
||||
{
|
||||
return $this->pemasukan_id ? 'pemasukan' : 'pengeluaran';
|
||||
}
|
||||
|
||||
|
||||
public function barang()
|
||||
{
|
||||
return $this->belongsTo(Barang::class);
|
||||
}
|
||||
|
||||
public function supplier()
|
||||
{
|
||||
return $this->belongsTo(Supplier::class);
|
||||
}
|
||||
|
||||
public function pengeluaran()
|
||||
{
|
||||
return $this->belongsTo(Pengeluaran::class);
|
||||
}
|
||||
|
||||
public function pemasukan()
|
||||
{
|
||||
return $this->belongsTo(Pemasukan::class);
|
||||
}
|
||||
|
||||
public function historyGajiKloter()
|
||||
{
|
||||
return $this->belongsTo(HistoryGajiKloter::class);
|
||||
}
|
||||
|
||||
public function getKodeGajiAttribute()
|
||||
{
|
||||
return $this->historyGajiKloter?->kode;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasApiTokens, HasFactory, Notifiable;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'role',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
// use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The model to policy mappings for the application.
|
||||
*
|
||||
* @var array<class-string, class-string>
|
||||
*/
|
||||
protected $policies = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Broadcast::routes();
|
||||
|
||||
require base_path('routes/channels.php');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event to listener mappings for the application.
|
||||
*
|
||||
* @var array<class-string, array<int, class-string>>
|
||||
*/
|
||||
protected $listen = [
|
||||
Registered::class => [
|
||||
SendEmailVerificationNotification::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any events for your application.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if events and listeners should be automatically discovered.
|
||||
*/
|
||||
public function shouldDiscoverEvents(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The path to your application's "home" route.
|
||||
*
|
||||
* Typically, users are redirected here after authentication.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/home';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, and other route configuration.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
|
||||
$this->routes(function () {
|
||||
Route::middleware('api')
|
||||
->prefix('api')
|
||||
->group(base_path('routes/api.php'));
|
||||
|
||||
Route::middleware('web')
|
||||
->group(base_path('routes/web.php'));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect user based on their role
|
||||
*/
|
||||
// public static function redirectToByRole($user)
|
||||
// {
|
||||
// return match ($user->role) {
|
||||
// 'pimpinan' => '/dashboard-pimpinan',
|
||||
// 'operator' => '/dashboard-operator',
|
||||
// default => '/dashboard',
|
||||
// };
|
||||
// }
|
||||
|
||||
public static function redirectToByRole($user)
|
||||
{
|
||||
if ($user->role === 'pimpinan') {
|
||||
return '/pimpinan/dashboard';
|
||||
} elseif ($user->role === 'operator') {
|
||||
return '/operator/dashboard';
|
||||
}
|
||||
|
||||
// Default redirect jika role tidak dikenal
|
||||
return '/';
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register The Auto Loader
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Composer provides a convenient, automatically generated class loader
|
||||
| for our application. We just need to utilize it! We'll require it
|
||||
| into the script here so that we do not have to worry about the
|
||||
| loading of any of our classes manually. It's great to relax.
|
||||
|
|
||||
*/
|
||||
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Run The Artisan Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When we run the console application, the current CLI command will be
|
||||
| executed in this console and the response sent back to a terminal
|
||||
| or another output device for the developers. Here goes nothing!
|
||||
|
|
||||
*/
|
||||
|
||||
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
|
||||
|
||||
$status = $kernel->handle(
|
||||
$input = new Symfony\Component\Console\Input\ArgvInput,
|
||||
new Symfony\Component\Console\Output\ConsoleOutput
|
||||
);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Shutdown The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Once Artisan has finished running, we will fire off the shutdown events
|
||||
| so that any final work may be done by the application before we shut
|
||||
| down the process. This is the last thing to happen to the request.
|
||||
|
|
||||
*/
|
||||
|
||||
$kernel->terminate($input, $status);
|
||||
|
||||
exit($status);
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Create The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The first thing we will do is create a new Laravel application instance
|
||||
| which serves as the "glue" for all the components of Laravel, and is
|
||||
| the IoC container for the system binding all of the various parts.
|
||||
|
|
||||
*/
|
||||
|
||||
$app = new Illuminate\Foundation\Application(
|
||||
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
|
||||
);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Bind Important Interfaces
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Next, we need to bind some important interfaces into the container so
|
||||
| we will be able to resolve them when needed. The kernels serve the
|
||||
| incoming requests to this application from both the web and CLI.
|
||||
|
|
||||
*/
|
||||
|
||||
$app->singleton(
|
||||
Illuminate\Contracts\Http\Kernel::class,
|
||||
App\Http\Kernel::class
|
||||
);
|
||||
|
||||
$app->singleton(
|
||||
Illuminate\Contracts\Console\Kernel::class,
|
||||
App\Console\Kernel::class
|
||||
);
|
||||
|
||||
$app->singleton(
|
||||
Illuminate\Contracts\Debug\ExceptionHandler::class,
|
||||
App\Exceptions\Handler::class
|
||||
);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Return The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This script returns the application instance. The instance is given to
|
||||
| the calling script so we can separate the building of the instances
|
||||
| from the actual running of the application and sending responses.
|
||||
|
|
||||
*/
|
||||
|
||||
return $app;
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
*
|
||||
!.gitignore
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
"name": "laravel/laravel",
|
||||
"type": "project",
|
||||
"description": "The skeleton application for the Laravel framework.",
|
||||
"keywords": ["laravel", "framework"],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.1",
|
||||
"guzzlehttp/guzzle": "^7.2",
|
||||
"laravel/framework": "^10.10",
|
||||
"laravel/sanctum": "^3.3",
|
||||
"laravel/tinker": "^2.8",
|
||||
"maatwebsite/excel": "^3.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.9.1",
|
||||
"laravel/breeze": "^1.29",
|
||||
"laravel/pint": "^1.0",
|
||||
"laravel/sail": "^1.18",
|
||||
"mockery/mockery": "^1.4.4",
|
||||
"nunomaduro/collision": "^7.0",
|
||||
"phpunit/phpunit": "^10.1",
|
||||
"spatie/laravel-ignition": "^2.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"Database\\Factories\\": "database/factories/",
|
||||
"Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"post-autoload-dump": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||
"@php artisan package:discover --ansi"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
|
||||
],
|
||||
"post-root-package-install": [
|
||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||
],
|
||||
"post-create-project-cmd": [
|
||||
"@php artisan key:generate --ansi"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"dont-discover": []
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"pestphp/pest-plugin": true,
|
||||
"php-http/discovery": true
|
||||
}
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"prefer-stable": true
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,189 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value is the name of your application. This value is used when the
|
||||
| framework needs to place the application's name in a notification or
|
||||
| any other location as required by the application or its packages.
|
||||
|
|
||||
*/
|
||||
|
||||
'name' => env('APP_NAME', 'Laravel'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Environment
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the "environment" your application is currently
|
||||
| running in. This may determine how you prefer to configure various
|
||||
| services the application utilizes. Set this in your ".env" file.
|
||||
|
|
||||
*/
|
||||
|
||||
'env' => env('APP_ENV', 'production'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Debug Mode
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When your application is in debug mode, detailed error messages with
|
||||
| stack traces will be shown on every error that occurs within your
|
||||
| application. If disabled, a simple generic error page is shown.
|
||||
|
|
||||
*/
|
||||
|
||||
'debug' => (bool) env('APP_DEBUG', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application URL
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This URL is used by the console to properly generate URLs when using
|
||||
| the Artisan command line tool. You should set this to the root of
|
||||
| your application so that it is used when running Artisan tasks.
|
||||
|
|
||||
*/
|
||||
|
||||
'url' => env('APP_URL', 'http://localhost'),
|
||||
|
||||
'asset_url' => env('ASSET_URL'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Timezone
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default timezone for your application, which
|
||||
| will be used by the PHP date and date-time functions. We have gone
|
||||
| ahead and set this to a sensible default for you out of the box.
|
||||
|
|
||||
*/
|
||||
|
||||
'timezone' => 'Asia/Jakarta',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Locale Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The application locale determines the default locale that will be used
|
||||
| by the translation service provider. You are free to set this value
|
||||
| to any of the locales which will be supported by the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'locale' => 'en',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Fallback Locale
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The fallback locale determines the locale to use when the current one
|
||||
| is not available. You may change the value to correspond to any of
|
||||
| the language folders that are provided through your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'fallback_locale' => 'en',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Faker Locale
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This locale will be used by the Faker PHP library when generating fake
|
||||
| data for your database seeds. For example, this will be used to get
|
||||
| localized telephone numbers, street address information and more.
|
||||
|
|
||||
*/
|
||||
|
||||
'faker_locale' => 'en_US',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Encryption Key
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This key is used by the Illuminate encrypter service and should be set
|
||||
| to a random, 32 character string, otherwise these encrypted strings
|
||||
| will not be safe. Please do this before deploying an application!
|
||||
|
|
||||
*/
|
||||
|
||||
'key' => env('APP_KEY'),
|
||||
|
||||
'cipher' => 'AES-256-CBC',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Maintenance Mode Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These configuration options determine the driver used to determine and
|
||||
| manage Laravel's "maintenance mode" status. The "cache" driver will
|
||||
| allow maintenance mode to be controlled across multiple machines.
|
||||
|
|
||||
| Supported drivers: "file", "cache"
|
||||
|
|
||||
*/
|
||||
|
||||
'maintenance' => [
|
||||
'driver' => 'file',
|
||||
// 'store' => 'redis',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Autoloaded Service Providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The service providers listed here will be automatically loaded on the
|
||||
| request to your application. Feel free to add your own services to
|
||||
| this array to grant expanded functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
'providers' => ServiceProvider::defaultProviders()->merge([
|
||||
/*
|
||||
* Package Service Providers...
|
||||
*/
|
||||
|
||||
/*
|
||||
* Application Service Providers...
|
||||
*/
|
||||
App\Providers\AppServiceProvider::class,
|
||||
App\Providers\AuthServiceProvider::class,
|
||||
// App\Providers\BroadcastServiceProvider::class,
|
||||
App\Providers\EventServiceProvider::class,
|
||||
App\Providers\RouteServiceProvider::class,
|
||||
])->toArray(),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Class Aliases
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This array of class aliases will be registered when this application
|
||||
| is started. However, feel free to register as many as you wish as
|
||||
| the aliases are "lazy" loaded so they don't hinder performance.
|
||||
|
|
||||
*/
|
||||
|
||||
'aliases' => Facade::defaultAliases()->merge([
|
||||
'PDF' => Barryvdh\DomPDF\Facade\Pdf::class,
|
||||
// 'Example' => App\Facades\Example::class,
|
||||
])->toArray(),
|
||||
|
||||
];
|
|
@ -0,0 +1,115 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Defaults
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default authentication "guard" and password
|
||||
| reset options for your application. You may change these defaults
|
||||
| as required, but they're a perfect start for most applications.
|
||||
|
|
||||
*/
|
||||
|
||||
'defaults' => [
|
||||
'guard' => 'web',
|
||||
'passwords' => 'users',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Guards
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Next, you may define every authentication guard for your application.
|
||||
| Of course, a great default configuration has been defined for you
|
||||
| here which uses session storage and the Eloquent user provider.
|
||||
|
|
||||
| All authentication drivers have a user provider. This defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| mechanisms used by this application to persist your user's data.
|
||||
|
|
||||
| Supported: "session"
|
||||
|
|
||||
*/
|
||||
|
||||
'guards' => [
|
||||
'web' => [
|
||||
'driver' => 'session',
|
||||
'provider' => 'users',
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| User Providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| All authentication drivers have a user provider. This defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| mechanisms used by this application to persist your user's data.
|
||||
|
|
||||
| If you have multiple user tables or models you may configure multiple
|
||||
| sources which represent each model / table. These sources may then
|
||||
| be assigned to any extra authentication guards you have defined.
|
||||
|
|
||||
| Supported: "database", "eloquent"
|
||||
|
|
||||
*/
|
||||
|
||||
'providers' => [
|
||||
'users' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => App\Models\User::class,
|
||||
],
|
||||
|
||||
// 'users' => [
|
||||
// 'driver' => 'database',
|
||||
// 'table' => 'users',
|
||||
// ],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Resetting Passwords
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| You may specify multiple password reset configurations if you have more
|
||||
| than one user table or model in the application and you want to have
|
||||
| separate password reset settings based on the specific user types.
|
||||
|
|
||||
| The expiry time is the number of minutes that each reset token will be
|
||||
| considered valid. This security feature keeps tokens short-lived so
|
||||
| they have less time to be guessed. You may change this as needed.
|
||||
|
|
||||
| The throttle setting is the number of seconds a user must wait before
|
||||
| generating more password reset tokens. This prevents the user from
|
||||
| quickly generating a very large amount of password reset tokens.
|
||||
|
|
||||
*/
|
||||
|
||||
'passwords' => [
|
||||
'users' => [
|
||||
'provider' => 'users',
|
||||
'table' => 'password_reset_tokens',
|
||||
'expire' => 60,
|
||||
'throttle' => 60,
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Confirmation Timeout
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define the amount of seconds before a password confirmation
|
||||
| times out and the user is prompted to re-enter their password via the
|
||||
| confirmation screen. By default, the timeout lasts for three hours.
|
||||
|
|
||||
*/
|
||||
|
||||
'password_timeout' => 10800,
|
||||
|
||||
];
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Broadcaster
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default broadcaster that will be used by the
|
||||
| framework when an event needs to be broadcast. You may set this to
|
||||
| any of the connections defined in the "connections" array below.
|
||||
|
|
||||
| Supported: "pusher", "ably", "redis", "log", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('BROADCAST_DRIVER', 'null'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Broadcast Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define all of the broadcast connections that will be used
|
||||
| to broadcast events to other systems or over websockets. Samples of
|
||||
| each available type of connection are provided inside this array.
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'pusher' => [
|
||||
'driver' => 'pusher',
|
||||
'key' => env('PUSHER_APP_KEY'),
|
||||
'secret' => env('PUSHER_APP_SECRET'),
|
||||
'app_id' => env('PUSHER_APP_ID'),
|
||||
'options' => [
|
||||
'cluster' => env('PUSHER_APP_CLUSTER'),
|
||||
'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
|
||||
'port' => env('PUSHER_PORT', 443),
|
||||
'scheme' => env('PUSHER_SCHEME', 'https'),
|
||||
'encrypted' => true,
|
||||
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
|
||||
],
|
||||
'client_options' => [
|
||||
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
|
||||
],
|
||||
],
|
||||
|
||||
'ably' => [
|
||||
'driver' => 'ably',
|
||||
'key' => env('ABLY_KEY'),
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => 'default',
|
||||
],
|
||||
|
||||
'log' => [
|
||||
'driver' => 'log',
|
||||
],
|
||||
|
||||
'null' => [
|
||||
'driver' => 'null',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default cache connection that gets used while
|
||||
| using this caching library. This connection is used when another is
|
||||
| not explicitly specified when executing a given caching function.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('CACHE_DRIVER', 'file'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Stores
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define all of the cache "stores" for your application as
|
||||
| well as their drivers. You may even define multiple stores for the
|
||||
| same cache driver to group types of items stored in your caches.
|
||||
|
|
||||
| Supported drivers: "apc", "array", "database", "file",
|
||||
| "memcached", "redis", "dynamodb", "octane", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'stores' => [
|
||||
|
||||
'apc' => [
|
||||
'driver' => 'apc',
|
||||
],
|
||||
|
||||
'array' => [
|
||||
'driver' => 'array',
|
||||
'serialize' => false,
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'table' => 'cache',
|
||||
'connection' => null,
|
||||
'lock_connection' => null,
|
||||
],
|
||||
|
||||
'file' => [
|
||||
'driver' => 'file',
|
||||
'path' => storage_path('framework/cache/data'),
|
||||
'lock_path' => storage_path('framework/cache/data'),
|
||||
],
|
||||
|
||||
'memcached' => [
|
||||
'driver' => 'memcached',
|
||||
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
|
||||
'sasl' => [
|
||||
env('MEMCACHED_USERNAME'),
|
||||
env('MEMCACHED_PASSWORD'),
|
||||
],
|
||||
'options' => [
|
||||
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
|
||||
],
|
||||
'servers' => [
|
||||
[
|
||||
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
|
||||
'port' => env('MEMCACHED_PORT', 11211),
|
||||
'weight' => 100,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => 'cache',
|
||||
'lock_connection' => 'default',
|
||||
],
|
||||
|
||||
'dynamodb' => [
|
||||
'driver' => 'dynamodb',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
|
||||
'endpoint' => env('DYNAMODB_ENDPOINT'),
|
||||
],
|
||||
|
||||
'octane' => [
|
||||
'driver' => 'octane',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Key Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing the APC, database, memcached, Redis, or DynamoDB cache
|
||||
| stores there might be other applications using the same cache. For
|
||||
| that reason, you may prefix every cache key to avoid collisions.
|
||||
|
|
||||
*/
|
||||
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'),
|
||||
|
||||
];
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cross-Origin Resource Sharing (CORS) Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure your settings for cross-origin resource sharing
|
||||
| or "CORS". This determines what cross-origin operations may execute
|
||||
| in web browsers. You are free to adjust these settings as needed.
|
||||
|
|
||||
| To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
||||
|
|
||||
*/
|
||||
|
||||
'paths' => ['api/*', 'sanctum/csrf-cookie'],
|
||||
|
||||
'allowed_methods' => ['*'],
|
||||
|
||||
'allowed_origins' => ['*'],
|
||||
|
||||
'allowed_origins_patterns' => [],
|
||||
|
||||
'allowed_headers' => ['*'],
|
||||
|
||||
'exposed_headers' => [],
|
||||
|
||||
'max_age' => 0,
|
||||
|
||||
'supports_credentials' => false,
|
||||
|
||||
];
|
|
@ -0,0 +1,151 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Database Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify which of the database connections below you wish
|
||||
| to use as your default connection for all database work. Of course
|
||||
| you may use many connections at once using the Database library.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('DB_CONNECTION', 'mysql'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Database Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here are each of the database connections setup for your application.
|
||||
| Of course, examples of configuring each database platform that is
|
||||
| supported by Laravel is shown below to make development simple.
|
||||
|
|
||||
|
|
||||
| All database work in Laravel is done through the PHP PDO facilities
|
||||
| so make sure you have the driver for your particular database of
|
||||
| choice installed on your machine before you begin development.
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sqlite' => [
|
||||
'driver' => 'sqlite',
|
||||
'url' => env('DATABASE_URL'),
|
||||
'database' => env('DB_DATABASE', database_path('database.sqlite')),
|
||||
'prefix' => '',
|
||||
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
|
||||
],
|
||||
|
||||
'mysql' => [
|
||||
'driver' => 'mysql',
|
||||
'url' => env('DATABASE_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => env('DB_DATABASE', 'forge'),
|
||||
'username' => env('DB_USERNAME', 'forge'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
'charset' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'pgsql' => [
|
||||
'driver' => 'pgsql',
|
||||
'url' => env('DATABASE_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '5432'),
|
||||
'database' => env('DB_DATABASE', 'forge'),
|
||||
'username' => env('DB_USERNAME', 'forge'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => 'utf8',
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'search_path' => 'public',
|
||||
'sslmode' => 'prefer',
|
||||
],
|
||||
|
||||
'sqlsrv' => [
|
||||
'driver' => 'sqlsrv',
|
||||
'url' => env('DATABASE_URL'),
|
||||
'host' => env('DB_HOST', 'localhost'),
|
||||
'port' => env('DB_PORT', '1433'),
|
||||
'database' => env('DB_DATABASE', 'forge'),
|
||||
'username' => env('DB_USERNAME', 'forge'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => 'utf8',
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
|
||||
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Migration Repository Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This table keeps track of all the migrations that have already run for
|
||||
| your application. Using this information, we can determine which of
|
||||
| the migrations on disk haven't actually been run in the database.
|
||||
|
|
||||
*/
|
||||
|
||||
'migrations' => 'migrations',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Redis Databases
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Redis is an open source, fast, and advanced key-value store that also
|
||||
| provides a richer body of commands than a typical key-value system
|
||||
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
||||
|
|
||||
*/
|
||||
|
||||
'redis' => [
|
||||
|
||||
'client' => env('REDIS_CLIENT', 'phpredis'),
|
||||
|
||||
'options' => [
|
||||
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
|
||||
],
|
||||
|
||||
'default' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_DB', '0'),
|
||||
],
|
||||
|
||||
'cache' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_CACHE_DB', '1'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Filesystem Disk
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default filesystem disk that should be used
|
||||
| by the framework. The "local" disk, as well as a variety of cloud
|
||||
| based disks are available to your application. Just store away!
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('FILESYSTEM_DISK', 'local'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Filesystem Disks
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure as many filesystem "disks" as you wish, and you
|
||||
| may even configure multiple disks of the same driver. Defaults have
|
||||
| been set up for each driver as an example of the required values.
|
||||
|
|
||||
| Supported Drivers: "local", "ftp", "sftp", "s3"
|
||||
|
|
||||
*/
|
||||
|
||||
'disks' => [
|
||||
|
||||
'local' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app'),
|
||||
'throw' => false,
|
||||
],
|
||||
|
||||
'public' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/public'),
|
||||
'url' => env('APP_URL').'/storage',
|
||||
'visibility' => 'public',
|
||||
'throw' => false,
|
||||
],
|
||||
|
||||
's3' => [
|
||||
'driver' => 's3',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION'),
|
||||
'bucket' => env('AWS_BUCKET'),
|
||||
'url' => env('AWS_URL'),
|
||||
'endpoint' => env('AWS_ENDPOINT'),
|
||||
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
||||
'throw' => false,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Symbolic Links
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the symbolic links that will be created when the
|
||||
| `storage:link` Artisan command is executed. The array keys should be
|
||||
| the locations of the links and the values should be their targets.
|
||||
|
|
||||
*/
|
||||
|
||||
'links' => [
|
||||
public_path('storage') => storage_path('app/public'),
|
||||
],
|
||||
|
||||
];
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Hash Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default hash driver that will be used to hash
|
||||
| passwords for your application. By default, the bcrypt algorithm is
|
||||
| used; however, you remain free to modify this option if you wish.
|
||||
|
|
||||
| Supported: "bcrypt", "argon", "argon2id"
|
||||
|
|
||||
*/
|
||||
|
||||
'driver' => 'bcrypt',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Bcrypt Options
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the configuration options that should be used when
|
||||
| passwords are hashed using the Bcrypt algorithm. This will allow you
|
||||
| to control the amount of time it takes to hash the given password.
|
||||
|
|
||||
*/
|
||||
|
||||
'bcrypt' => [
|
||||
'rounds' => env('BCRYPT_ROUNDS', 12),
|
||||
'verify' => true,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Argon Options
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the configuration options that should be used when
|
||||
| passwords are hashed using the Argon algorithm. These will allow you
|
||||
| to control the amount of time it takes to hash the given password.
|
||||
|
|
||||
*/
|
||||
|
||||
'argon' => [
|
||||
'memory' => 65536,
|
||||
'threads' => 1,
|
||||
'time' => 4,
|
||||
'verify' => true,
|
||||
],
|
||||
|
||||
];
|
|
@ -0,0 +1,131 @@
|
|||
<?php
|
||||
|
||||
use Monolog\Handler\NullHandler;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Handler\SyslogUdpHandler;
|
||||
use Monolog\Processor\PsrLogMessageProcessor;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option defines the default log channel that gets used when writing
|
||||
| messages to the logs. The name specified in this option should match
|
||||
| one of the channels defined in the "channels" configuration array.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('LOG_CHANNEL', 'stack'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Deprecations Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the log channel that should be used to log warnings
|
||||
| regarding deprecated PHP and library features. This allows you to get
|
||||
| your application ready for upcoming major versions of dependencies.
|
||||
|
|
||||
*/
|
||||
|
||||
'deprecations' => [
|
||||
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
|
||||
'trace' => false,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Log Channels
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the log channels for your application. Out of
|
||||
| the box, Laravel uses the Monolog PHP logging library. This gives
|
||||
| you a variety of powerful log handlers / formatters to utilize.
|
||||
|
|
||||
| Available Drivers: "single", "daily", "slack", "syslog",
|
||||
| "errorlog", "monolog",
|
||||
| "custom", "stack"
|
||||
|
|
||||
*/
|
||||
|
||||
'channels' => [
|
||||
'stack' => [
|
||||
'driver' => 'stack',
|
||||
'channels' => ['single'],
|
||||
'ignore_exceptions' => false,
|
||||
],
|
||||
|
||||
'single' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'daily' => [
|
||||
'driver' => 'daily',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'days' => 14,
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'driver' => 'slack',
|
||||
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||
'username' => 'Laravel Log',
|
||||
'emoji' => ':boom:',
|
||||
'level' => env('LOG_LEVEL', 'critical'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'papertrail' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
|
||||
'handler_with' => [
|
||||
'host' => env('PAPERTRAIL_URL'),
|
||||
'port' => env('PAPERTRAIL_PORT'),
|
||||
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
|
||||
],
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
],
|
||||
|
||||
'stderr' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => StreamHandler::class,
|
||||
'formatter' => env('LOG_STDERR_FORMATTER'),
|
||||
'with' => [
|
||||
'stream' => 'php://stderr',
|
||||
],
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
],
|
||||
|
||||
'syslog' => [
|
||||
'driver' => 'syslog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'facility' => LOG_USER,
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'errorlog' => [
|
||||
'driver' => 'errorlog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'null' => [
|
||||
'driver' => 'monolog',
|
||||
'handler' => NullHandler::class,
|
||||
],
|
||||
|
||||
'emergency' => [
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
],
|
||||
],
|
||||
|
||||
];
|
|
@ -0,0 +1,134 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Mailer
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default mailer that is used to send any email
|
||||
| messages sent by your application. Alternative mailers may be setup
|
||||
| and used as needed; however, this mailer will be used by default.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('MAIL_MAILER', 'smtp'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Mailer Configurations
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure all of the mailers used by your application plus
|
||||
| their respective settings. Several examples have been configured for
|
||||
| you and you are free to add your own as your application requires.
|
||||
|
|
||||
| Laravel supports a variety of mail "transport" drivers to be used while
|
||||
| sending an e-mail. You will specify which one you are using for your
|
||||
| mailers below. You are free to add additional mailers as required.
|
||||
|
|
||||
| Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
|
||||
| "postmark", "log", "array", "failover", "roundrobin"
|
||||
|
|
||||
*/
|
||||
|
||||
'mailers' => [
|
||||
'smtp' => [
|
||||
'transport' => 'smtp',
|
||||
'url' => env('MAIL_URL'),
|
||||
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
|
||||
'port' => env('MAIL_PORT', 587),
|
||||
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
|
||||
'username' => env('MAIL_USERNAME'),
|
||||
'password' => env('MAIL_PASSWORD'),
|
||||
'timeout' => null,
|
||||
'local_domain' => env('MAIL_EHLO_DOMAIN'),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'transport' => 'ses',
|
||||
],
|
||||
|
||||
'postmark' => [
|
||||
'transport' => 'postmark',
|
||||
// 'message_stream_id' => null,
|
||||
// 'client' => [
|
||||
// 'timeout' => 5,
|
||||
// ],
|
||||
],
|
||||
|
||||
'mailgun' => [
|
||||
'transport' => 'mailgun',
|
||||
// 'client' => [
|
||||
// 'timeout' => 5,
|
||||
// ],
|
||||
],
|
||||
|
||||
'sendmail' => [
|
||||
'transport' => 'sendmail',
|
||||
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
|
||||
],
|
||||
|
||||
'log' => [
|
||||
'transport' => 'log',
|
||||
'channel' => env('MAIL_LOG_CHANNEL'),
|
||||
],
|
||||
|
||||
'array' => [
|
||||
'transport' => 'array',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'transport' => 'failover',
|
||||
'mailers' => [
|
||||
'smtp',
|
||||
'log',
|
||||
],
|
||||
],
|
||||
|
||||
'roundrobin' => [
|
||||
'transport' => 'roundrobin',
|
||||
'mailers' => [
|
||||
'ses',
|
||||
'postmark',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Global "From" Address
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| You may wish for all e-mails sent by your application to be sent from
|
||||
| the same address. Here, you may specify a name and address that is
|
||||
| used globally for all e-mails that are sent by your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'from' => [
|
||||
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
|
||||
'name' => env('MAIL_FROM_NAME', 'Example'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Markdown Mail Settings
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If you are using Markdown based email rendering, you may configure your
|
||||
| theme and component paths here, allowing you to customize the design
|
||||
| of the emails. Or, you may simply stick with the Laravel defaults!
|
||||
|
|
||||
*/
|
||||
|
||||
'markdown' => [
|
||||
'theme' => 'default',
|
||||
|
||||
'paths' => [
|
||||
resource_path('views/vendor/mail'),
|
||||
],
|
||||
],
|
||||
|
||||
];
|
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Queue Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Laravel's queue API supports an assortment of back-ends via a single
|
||||
| API, giving you convenient access to each back-end using the same
|
||||
| syntax for every one. Here you may define a default connection.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('QUEUE_CONNECTION', 'sync'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Queue Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the connection information for each server that
|
||||
| is used by your application. A default configuration has been added
|
||||
| for each back-end shipped with Laravel. You are free to add more.
|
||||
|
|
||||
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sync' => [
|
||||
'driver' => 'sync',
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'table' => 'jobs',
|
||||
'queue' => 'default',
|
||||
'retry_after' => 90,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'beanstalkd' => [
|
||||
'driver' => 'beanstalkd',
|
||||
'host' => 'localhost',
|
||||
'queue' => 'default',
|
||||
'retry_after' => 90,
|
||||
'block_for' => 0,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'sqs' => [
|
||||
'driver' => 'sqs',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
|
||||
'queue' => env('SQS_QUEUE', 'default'),
|
||||
'suffix' => env('SQS_SUFFIX'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => 'default',
|
||||
'queue' => env('REDIS_QUEUE', 'default'),
|
||||
'retry_after' => 90,
|
||||
'block_for' => null,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Job Batching
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following options configure the database and table that store job
|
||||
| batching information. These options can be updated to any database
|
||||
| connection and table which has been defined by your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'batching' => [
|
||||
'database' => env('DB_CONNECTION', 'mysql'),
|
||||
'table' => 'job_batches',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Failed Queue Jobs
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These options configure the behavior of failed queue job logging so you
|
||||
| can control which database and table are used to store the jobs that
|
||||
| have failed. You may change them to any database / table you wish.
|
||||
|
|
||||
*/
|
||||
|
||||
'failed' => [
|
||||
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
|
||||
'database' => env('DB_CONNECTION', 'mysql'),
|
||||
'table' => 'failed_jobs',
|
||||
],
|
||||
|
||||
];
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Stateful Domains
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Requests from the following domains / hosts will receive stateful API
|
||||
| authentication cookies. Typically, these should include your local
|
||||
| and production domains which access your API via a frontend SPA.
|
||||
|
|
||||
*/
|
||||
|
||||
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
|
||||
'%s%s',
|
||||
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
|
||||
Sanctum::currentApplicationUrlWithPort()
|
||||
))),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Sanctum Guards
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This array contains the authentication guards that will be checked when
|
||||
| Sanctum is trying to authenticate a request. If none of these guards
|
||||
| are able to authenticate the request, Sanctum will use the bearer
|
||||
| token that's present on an incoming request for authentication.
|
||||
|
|
||||
*/
|
||||
|
||||
'guard' => ['web'],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Expiration Minutes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value controls the number of minutes until an issued token will be
|
||||
| considered expired. This will override any values set in the token's
|
||||
| "expires_at" attribute, but first-party sessions are not affected.
|
||||
|
|
||||
*/
|
||||
|
||||
'expiration' => null,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Token Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Sanctum can prefix new tokens in order to take advantage of numerous
|
||||
| security scanning initiatives maintained by open source platforms
|
||||
| that notify developers if they commit tokens into repositories.
|
||||
|
|
||||
| See: https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning
|
||||
|
|
||||
*/
|
||||
|
||||
'token_prefix' => env('SANCTUM_TOKEN_PREFIX', ''),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Sanctum Middleware
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When authenticating your first-party SPA with Sanctum you may need to
|
||||
| customize some of the middleware Sanctum uses while processing the
|
||||
| request. You may change the middleware listed below as required.
|
||||
|
|
||||
*/
|
||||
|
||||
'middleware' => [
|
||||
'authenticate_session' => Laravel\Sanctum\Http\Middleware\AuthenticateSession::class,
|
||||
'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class,
|
||||
'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class,
|
||||
],
|
||||
|
||||
];
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Third Party Services
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This file is for storing the credentials for third party services such
|
||||
| as Mailgun, Postmark, AWS and more. This file provides the de facto
|
||||
| location for this type of information, allowing packages to have
|
||||
| a conventional file to locate the various service credentials.
|
||||
|
|
||||
*/
|
||||
|
||||
'mailgun' => [
|
||||
'domain' => env('MAILGUN_DOMAIN'),
|
||||
'secret' => env('MAILGUN_SECRET'),
|
||||
'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
|
||||
'scheme' => 'https',
|
||||
],
|
||||
|
||||
'postmark' => [
|
||||
'token' => env('POSTMARK_TOKEN'),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
],
|
||||
|
||||
];
|
|
@ -0,0 +1,214 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Session Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default session "driver" that will be used on
|
||||
| requests. By default, we will use the lightweight native driver but
|
||||
| you may specify any of the other wonderful drivers provided here.
|
||||
|
|
||||
| Supported: "file", "cookie", "database", "apc",
|
||||
| "memcached", "redis", "dynamodb", "array"
|
||||
|
|
||||
*/
|
||||
|
||||
'driver' => env('SESSION_DRIVER', 'file'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Lifetime
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the number of minutes that you wish the session
|
||||
| to be allowed to remain idle before it expires. If you want them
|
||||
| to immediately expire on the browser closing, set that option.
|
||||
|
|
||||
*/
|
||||
|
||||
'lifetime' => env('SESSION_LIFETIME', 120),
|
||||
|
||||
'expire_on_close' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Encryption
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option allows you to easily specify that all of your session data
|
||||
| should be encrypted before it is stored. All encryption will be run
|
||||
| automatically by Laravel and you can use the Session like normal.
|
||||
|
|
||||
*/
|
||||
|
||||
'encrypt' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session File Location
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the native session driver, we need a location where session
|
||||
| files may be stored. A default has been set for you but a different
|
||||
| location may be specified. This is only needed for file sessions.
|
||||
|
|
||||
*/
|
||||
|
||||
'files' => storage_path('framework/sessions'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Connection
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" or "redis" session drivers, you may specify a
|
||||
| connection that should be used to manage these sessions. This should
|
||||
| correspond to a connection in your database configuration options.
|
||||
|
|
||||
*/
|
||||
|
||||
'connection' => env('SESSION_CONNECTION'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" session driver, you may specify the table we
|
||||
| should use to manage the sessions. Of course, a sensible default is
|
||||
| provided for you; however, you are free to change this as needed.
|
||||
|
|
||||
*/
|
||||
|
||||
'table' => 'sessions',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| While using one of the framework's cache driven session backends you may
|
||||
| list a cache store that should be used for these sessions. This value
|
||||
| must match with one of the application's configured cache "stores".
|
||||
|
|
||||
| Affects: "apc", "dynamodb", "memcached", "redis"
|
||||
|
|
||||
*/
|
||||
|
||||
'store' => env('SESSION_STORE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Sweeping Lottery
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Some session drivers must manually sweep their storage location to get
|
||||
| rid of old sessions from storage. Here are the chances that it will
|
||||
| happen on a given request. By default, the odds are 2 out of 100.
|
||||
|
|
||||
*/
|
||||
|
||||
'lottery' => [2, 100],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may change the name of the cookie used to identify a session
|
||||
| instance by ID. The name specified here will get used every time a
|
||||
| new session cookie is created by the framework for every driver.
|
||||
|
|
||||
*/
|
||||
|
||||
'cookie' => env(
|
||||
'SESSION_COOKIE',
|
||||
Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The session cookie path determines the path for which the cookie will
|
||||
| be regarded as available. Typically, this will be the root path of
|
||||
| your application but you are free to change this when necessary.
|
||||
|
|
||||
*/
|
||||
|
||||
'path' => '/',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Domain
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may change the domain of the cookie used to identify a session
|
||||
| in your application. This will determine which domains the cookie is
|
||||
| available to in your application. A sensible default has been set.
|
||||
|
|
||||
*/
|
||||
|
||||
'domain' => env('SESSION_DOMAIN'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTPS Only Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By setting this option to true, session cookies will only be sent back
|
||||
| to the server if the browser has a HTTPS connection. This will keep
|
||||
| the cookie from being sent to you when it can't be done securely.
|
||||
|
|
||||
*/
|
||||
|
||||
'secure' => env('SESSION_SECURE_COOKIE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTP Access Only
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting this value to true will prevent JavaScript from accessing the
|
||||
| value of the cookie and the cookie will only be accessible through
|
||||
| the HTTP protocol. You are free to modify this option if needed.
|
||||
|
|
||||
*/
|
||||
|
||||
'http_only' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Same-Site Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines how your cookies behave when cross-site requests
|
||||
| take place, and can be used to mitigate CSRF attacks. By default, we
|
||||
| will set this value to "lax" since this is a secure default value.
|
||||
|
|
||||
| Supported: "lax", "strict", "none", null
|
||||
|
|
||||
*/
|
||||
|
||||
'same_site' => 'lax',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Partitioned Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting this value to true will tie the cookie to the top-level site for
|
||||
| a cross-site context. Partitioned cookies are accepted by the browser
|
||||
| when flagged "secure" and the Same-Site attribute is set to "none".
|
||||
|
|
||||
*/
|
||||
|
||||
'partitioned' => false,
|
||||
|
||||
];
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| View Storage Paths
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Most templating systems load templates from disk. Here you may specify
|
||||
| an array of paths that should be checked for your views. Of course
|
||||
| the usual Laravel view path has already been registered for you.
|
||||
|
|
||||
*/
|
||||
|
||||
'paths' => [
|
||||
resource_path('views'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Compiled View Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines where all the compiled Blade templates will be
|
||||
| stored for your application. Typically, this is within the storage
|
||||
| directory. However, as usual, you are free to change this value.
|
||||
|
|
||||
*/
|
||||
|
||||
'compiled' => env(
|
||||
'VIEW_COMPILED_PATH',
|
||||
realpath(storage_path('framework/views'))
|
||||
),
|
||||
|
||||
];
|
|
@ -0,0 +1 @@
|
|||
*.sqlite*
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->string('role')->default('operator');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('personal_access_tokens', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('tokenable');
|
||||
$table->string('name');
|
||||
$table->string('token', 64)->unique();
|
||||
$table->text('abilities')->nullable();
|
||||
$table->timestamp('last_used_at')->nullable();
|
||||
$table->timestamp('expires_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('personal_access_tokens');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('karyawans', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nama');
|
||||
$table->enum('jenis_kelamin', ['L', 'P'])->default('L');
|
||||
$table->string('no_telepon')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('karyawan');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('kloters', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nama_kloter');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('kloters');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('presensis', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('karyawan_id')->nullable()->constrained()->onDelete('cascade');
|
||||
$table->foreignId('kloter_id')->nullable()->constrained()->onDelete('cascade');
|
||||
$table->date('tanggal');
|
||||
$table->time('jam_masuk')->nullable();
|
||||
$table->time('jam_pulang')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('presensis');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('ton_ikans', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('kloter_id')->nullable()->constrained('kloters')->onDelete('set null');
|
||||
$table->decimal('jumlah_ton', 8, 2);
|
||||
$table->bigInteger('harga_ikan_per_ton')->default(1000000);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ton_ikans');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('barangs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nama_barang')->collation('utf8mb4_unicode_ci')->unique();
|
||||
$table->integer('qty')->nullable();
|
||||
$table->date('exp')->nullable();
|
||||
$table->integer('harga');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('barang');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('barang_pendukungs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('barang_id')->constrained('barangs')->onDelete('cascade');
|
||||
$table->string('kode')->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('barang_pendukungs');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('barang_produks', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('barang_id')->constrained('barangs')->onDelete('cascade');
|
||||
$table->string('kode')->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('barangs');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('suppliers', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nama');
|
||||
$table->text('alamat');
|
||||
$table->string('no_tlp');
|
||||
$table->string('no_rekening')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('suppliers');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('pemasoks', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('supplier_id')->constrained('suppliers')->onDelete('cascade');
|
||||
$table->string('kode')->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('pemasok');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('konsumens', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('supplier_id')->constrained('suppliers')->onDelete('cascade');
|
||||
$table->string('kode')->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('konsumen');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('pemasukans', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('kode')->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('pemasukans');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('pengeluarans', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('kode')->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('pengeluarans');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('kloter_karyawans', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('kloter_id')->constrained()->onDelete('cascade');
|
||||
$table->foreignId('karyawan_id')->constrained()->onDelete('cascade');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('kloter_karyawans');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('history_gaji_kloters', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('kloter_id')->nullable()->constrained('kloters')->onDelete('cascade');
|
||||
$table->string('kode')->unique()->nullable();
|
||||
$table->integer('jml_karyawan');
|
||||
$table->double('total_gaji');
|
||||
$table->timestamp('waktu');
|
||||
$table->date('tanggal_awal')->nullable();
|
||||
$table->date('tanggal_akhir')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('history_gaji_kloter');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('transaksis', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('barang_id')->nullable()->constrained('barangs')->onDelete('cascade');
|
||||
$table->foreignId('supplier_id')->nullable()->constrained('suppliers')->onDelete('cascade');
|
||||
$table->foreignId('pengeluaran_id')->nullable()->constrained('pengeluarans')->onDelete('cascade');
|
||||
$table->foreignId('pemasukan_id')->nullable()->constrained('pemasukans')->onDelete('cascade');
|
||||
$table->foreignId('history_gaji_kloter_id')->nullable()->constrained('history_gaji_kloters')->onDelete('set null');
|
||||
$table->double('jumlahRp');
|
||||
$table->integer('qtyHistori')->default(0);
|
||||
$table->string('satuan')->default('kg');
|
||||
$table->dateTime('waktu_transaksi');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('transaksis');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\BarangPendukung;
|
||||
|
||||
class BarangPendukungSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
BarangPendukung::insert([
|
||||
['barang_id' => 1, 'kode' => 'PDN001'],
|
||||
['barang_id' => 2, 'kode' => 'PDN002'],
|
||||
['barang_id' => 3, 'kode' => 'PDN003'],
|
||||
['barang_id' => 4, 'kode' => 'PDN004'],
|
||||
['barang_id' => 5, 'kode' => 'PDN005'],
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\BarangProduk;
|
||||
|
||||
class BarangProdukSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
BarangProduk::insert([
|
||||
['barang_id' => 1, 'kode' => 'PRD001'],
|
||||
['barang_id' => 2, 'kode' => 'PRD002'],
|
||||
['barang_id' => 3, 'kode' => 'PRD003'],
|
||||
['barang_id' => 4, 'kode' => 'PRD004'],
|
||||
['barang_id' => 5, 'kode' => 'PRD005'],
|
||||
]);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue