Siopas Inventory PETI for ISTW Website
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

80 lines
2.0 KiB

<?php
namespace App\Models;
use App\Traits\UUID;
use App\Models\Customer;
use App\Models\Type_peti;
use App\Models\Kondisi_Peti;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Peti extends Model
{
use HasFactory, SoftDeletes;
protected $table = 'petis';
protected $fillable = [
'tipe_peti_id', //
'warna', //
'customer_id', //
'warehouse_id', //
't_warehouse_id', //
'kondisipeti_id', //
'jumlah',
'date_pembuatan', //
'packing_no', //
'fix_lot', //
'status', //
'status_isi', //
'created_by', //
'updated_by', //
];
public function customer()
{
return $this->belongsTo(Customer::class, 'customer_id')->select(
'id',
'name',
'code_customer',
'lot_no'
)->withTrashed();
}
public function warehouse()
{
return $this->belongsTo(m_warehouse::class, 'warehouse_id')->select('id', 'name', 'address')->withTrashed();
}
public function t_warehouse()
{
return $this->belongsTo(m_warehouse::class, 't_warehouse_id');
}
public function tipe_peti()
{
return $this->belongsTo(Type_peti::class, 'tipe_peti_id')->select(
'id',
'type',
'size_peti',
'description'
)->withTrashed();
}
public function kondisipeti()
{
return $this->belongsTo(Kondisi_Peti::class, 'kondisipeti_id')->select(
'id',
'nama_kondisi',
'deskripsi_kondisi'
)->withTrashed();
}
public function transfer()
{
return $this->hasOne(Transfer::class, 'peti_id')->withTrashed();
}
// proses pengambilan data
public function assetStatuses()
{
return $this->hasMany(asset_status::class, 'peti_id')->withTrashed();
}
}