Update Fix
This commit is contained in:
16
app/Models/Distributor.php
Normal file
16
app/Models/Distributor.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Distributor extends Model
|
||||
{
|
||||
protected $table = 'distributors';
|
||||
|
||||
protected $fillable = [
|
||||
'nama',
|
||||
'alamat',
|
||||
'telepon',
|
||||
];
|
||||
}
|
||||
15
app/Models/Lokasi.php
Normal file
15
app/Models/Lokasi.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Lokasi extends Model
|
||||
{
|
||||
protected $table = 'lokasi';
|
||||
|
||||
protected $fillable = [
|
||||
'kode',
|
||||
'nama'
|
||||
];
|
||||
}
|
||||
25
app/Models/Pegawai.php
Normal file
25
app/Models/Pegawai.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Pegawai extends Model
|
||||
{
|
||||
protected $table = 'pegawai';
|
||||
|
||||
protected $fillable = [
|
||||
'nip',
|
||||
'nama',
|
||||
'jabatan',
|
||||
'telepon',
|
||||
'alamat',
|
||||
'tempat_lahir',
|
||||
'tanggal_lahir',
|
||||
'jenis_kelamin',
|
||||
'kota',
|
||||
'nik',
|
||||
'foto',
|
||||
'is_aktif',
|
||||
];
|
||||
}
|
||||
51
app/Models/PenerimaanBarang.php
Normal file
51
app/Models/PenerimaanBarang.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class PenerimaanBarang extends Model
|
||||
{
|
||||
protected $table = 'penerimaan_barang';
|
||||
|
||||
protected $fillable = [
|
||||
'nomor_penerimaan',
|
||||
'no_faktur',
|
||||
'tanggal_faktur',
|
||||
'tanggal_datang',
|
||||
'distributor_id',
|
||||
'lokasi_id',
|
||||
'user_id',
|
||||
'status',
|
||||
'catatan',
|
||||
'applied_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'tanggal_faktur' => 'date',
|
||||
'tanggal_datang' => 'date',
|
||||
'applied_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function items(): HasMany
|
||||
{
|
||||
return $this->hasMany(PenerimaanBarangItem::class, 'penerimaan_id');
|
||||
}
|
||||
|
||||
public function distributor(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Distributor::class, 'distributor_id');
|
||||
}
|
||||
|
||||
public function lokasi(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Lokasi::class, 'lokasi_id');
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
}
|
||||
32
app/Models/PenerimaanBarangItem.php
Normal file
32
app/Models/PenerimaanBarangItem.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class PenerimaanBarangItem extends Model
|
||||
{
|
||||
protected $table = 'penerimaan_barang_items';
|
||||
|
||||
protected $fillable = [
|
||||
'penerimaan_id',
|
||||
'produk_id',
|
||||
'unit_id',
|
||||
'qty',
|
||||
'qty_input',
|
||||
'harga',
|
||||
'unit',
|
||||
'multiplier',
|
||||
];
|
||||
|
||||
public function penerimaan(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PenerimaanBarang::class, 'penerimaan_id');
|
||||
}
|
||||
|
||||
public function produk(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Produk::class, 'produk_id');
|
||||
}
|
||||
}
|
||||
39
app/Models/Penjualan.php
Normal file
39
app/Models/Penjualan.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\User;
|
||||
|
||||
class Penjualan extends Model
|
||||
{
|
||||
protected $table = 'penjualan';
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'nomor_penjualan',
|
||||
'waktu',
|
||||
'subtotal',
|
||||
'diskon',
|
||||
'pajak',
|
||||
'total',
|
||||
'metode_pembayaran',
|
||||
'status_pembayaran',
|
||||
'voucher_kode',
|
||||
'voucher_amount',
|
||||
'unit_piutang',
|
||||
'jumlah_bayar',
|
||||
'kembalian',
|
||||
'sisa_piutang',
|
||||
];
|
||||
|
||||
public function barang()
|
||||
{
|
||||
return $this->hasMany(PenjualanBarang::class, 'penjualan_id');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
}
|
||||
24
app/Models/PenjualanBarang.php
Normal file
24
app/Models/PenjualanBarang.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\Produk;
|
||||
|
||||
class PenjualanBarang extends Model
|
||||
{
|
||||
protected $table = 'penjualan_barang';
|
||||
|
||||
protected $fillable = [
|
||||
'penjualan_id',
|
||||
'produk_id',
|
||||
'jumlah',
|
||||
'harga',
|
||||
'total'
|
||||
];
|
||||
|
||||
public function produk()
|
||||
{
|
||||
return $this->belongsTo(Produk::class, 'produk_id');
|
||||
}
|
||||
}
|
||||
40
app/Models/PergerakanStok.php
Normal file
40
app/Models/PergerakanStok.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PergerakanStok extends Model
|
||||
{
|
||||
protected $table = 'pergerakan_stok';
|
||||
|
||||
protected $fillable = [
|
||||
'waktu',
|
||||
'produk_id',
|
||||
'dari_lokasi_id',
|
||||
'ke_lokasi_id',
|
||||
'jenis',
|
||||
'jumlah',
|
||||
'unit',
|
||||
'qty_input',
|
||||
'multiplier',
|
||||
'catatan',
|
||||
'referensi_tipe',
|
||||
'referensi_id'
|
||||
];
|
||||
|
||||
public function produk()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Produk::class, 'produk_id');
|
||||
}
|
||||
|
||||
public function dariLokasi()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Lokasi::class, 'dari_lokasi_id');
|
||||
}
|
||||
|
||||
public function keLokasi()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Lokasi::class, 'ke_lokasi_id');
|
||||
}
|
||||
}
|
||||
20
app/Models/PiutangPayment.php
Normal file
20
app/Models/PiutangPayment.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PiutangPayment extends Model
|
||||
{
|
||||
protected $table = 'piutang_payments';
|
||||
|
||||
protected $fillable = [
|
||||
'penjualan_id',
|
||||
'jumlah',
|
||||
'metode',
|
||||
'catatan',
|
||||
'user_id',
|
||||
'sisa_before',
|
||||
'sisa_after',
|
||||
];
|
||||
}
|
||||
22
app/Models/ProductUnit.php
Normal file
22
app/Models/ProductUnit.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ProductUnit extends Model
|
||||
{
|
||||
protected $table = 'produk_unit';
|
||||
|
||||
protected $fillable = [
|
||||
'produk_id',
|
||||
'nama_unit',
|
||||
'multiplier',
|
||||
'is_base',
|
||||
];
|
||||
|
||||
public function produk()
|
||||
{
|
||||
return $this->belongsTo(Produk::class);
|
||||
}
|
||||
}
|
||||
27
app/Models/Produk.php
Normal file
27
app/Models/Produk.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\ProductUnit;
|
||||
|
||||
class Produk extends Model
|
||||
{
|
||||
protected $table = 'produk';
|
||||
|
||||
protected $fillable = [
|
||||
'sku',
|
||||
'nama',
|
||||
'barcode',
|
||||
'harga_beli',
|
||||
'harga_jual',
|
||||
'is_aktif',
|
||||
];
|
||||
|
||||
public function units() {
|
||||
return $this->hasMany(ProductUnit::class, 'produk_id');
|
||||
}
|
||||
public function baseUnit() {
|
||||
return $this->hasOne(ProductUnit::class, 'produk_id')->where('is_base', true);
|
||||
}
|
||||
}
|
||||
15
app/Models/Setting.php
Normal file
15
app/Models/Setting.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Setting extends Model
|
||||
{
|
||||
protected $table = 'settings';
|
||||
|
||||
protected $fillable = [
|
||||
'key',
|
||||
'value',
|
||||
];
|
||||
}
|
||||
62
app/Models/User.php
Normal file
62
app/Models/User.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
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;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'role',
|
||||
'nip',
|
||||
'pegawai_id',
|
||||
];
|
||||
|
||||
public const ROLE_ADMIN = 'admin';
|
||||
public const ROLE_KASIR = 'kasir';
|
||||
public const ROLE_GUDANG = 'gudang';
|
||||
|
||||
public function isAdmin(): bool
|
||||
{
|
||||
return $this->role === self::ROLE_ADMIN;
|
||||
}
|
||||
|
||||
public function pegawai()
|
||||
{
|
||||
return $this->belongsTo(Pegawai::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
25
app/Models/Voucher.php
Normal file
25
app/Models/Voucher.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Voucher extends Model
|
||||
{
|
||||
protected $table = 'vouchers';
|
||||
|
||||
protected $fillable = [
|
||||
'pegawai_id',
|
||||
'kode',
|
||||
'saldo',
|
||||
'aktif',
|
||||
'catatan',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
public function pegawai(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Pegawai::class, 'pegawai_id');
|
||||
}
|
||||
}
|
||||
22
app/Models/VoucherHistory.php
Normal file
22
app/Models/VoucherHistory.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class VoucherHistory extends Model
|
||||
{
|
||||
protected $table = 'voucher_histories';
|
||||
|
||||
protected $fillable = [
|
||||
'voucher_id',
|
||||
'kode',
|
||||
'tipe',
|
||||
'jumlah',
|
||||
'saldo_before',
|
||||
'saldo_after',
|
||||
'penjualan_id',
|
||||
'user_id',
|
||||
'catatan',
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user