<?php

/**
 * Created by Reliese Model.
 */

namespace App\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;

/**
 * Class DataInventarisMaster
 *
 * @property string $id
 * @property int $jenis_id
 * @property int $sumber
 * @property string $nama
 * @property Carbon $tgl_perolehan
 * @property Carbon $tgl_habis
 * @property Carbon $tgl_hapus
 * @property int $nilai_perolehan
 * @property int|null $nilai_susut
 * @property string $keterangan
 * @property int $status
 *
 * @property DataInventarisJeni $data_inventaris_jeni
 * @property Collection|DataInventarisHapusBuku[] $data_inventaris_hapus_bukus
 * @property Collection|DataInventarisTran[] $data_inventaris_trans
 *
 * @package App\Models
 */
class Inventaris extends Model
{
	protected $table = 'data_inventaris_master';
	public $incrementing = false;
	public $timestamps = false;

	protected $casts = [
		'jenis_id' => 'int',
		'sumber' => 'int',
		'tgl_perolehan' => 'datetime',
		'tgl_habis' => 'datetime',
		'tgl_hapus' => 'datetime',
		'nilai_perolehan' => 'int',
		'nilai_susut' => 'int',
		'status' => 'int'
	];

	protected $fillable = [
		'jenis_id',
		'sumber',
		'nama',
		'tgl_perolehan',
		'tgl_habis',
		'tgl_hapus',
		'nilai_perolehan',
		'nilai_susut',
		'keterangan',
		'status'
	];

	public function jenis()
	{
		return $this->belongsTo(InventarisJenis::class, 'jenis_id');
	}

	public function transaksi_hapus_buku()
	{
		return $this->hasMany(InventarisTransHapusBuku::class, 'inventaris_id');
	}

	public function transaksi()
	{
		return $this->hasMany(InventarisTrans::class, 'inventaris_id');
	}
}
