111 lines
2.3 KiB
PHP
111 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
class Customer extends Model
|
|
{
|
|
|
|
protected $table = 'customer';
|
|
public $timestamps = false;
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $primaryKey = ['kplama','kpbaru'];
|
|
public $incrementing = false;
|
|
protected $fillable = [
|
|
'ahli',
|
|
'kodcaw',
|
|
'nosiri',
|
|
'tarikhdaftar',
|
|
'nopelanggan',
|
|
'kplama',
|
|
'kpbaru',
|
|
'nama',
|
|
't_lahir',
|
|
'jantina',
|
|
'alamat1',
|
|
'alamat2',
|
|
'alamat3',
|
|
'alamat4',
|
|
'poskod',
|
|
'koddaerah',
|
|
'kodnegeri',
|
|
'telefon',
|
|
'jumpinjaman',
|
|
't_gadai',
|
|
'pinjamhari',
|
|
'bumiputra',
|
|
'warganegara',
|
|
'bangsa',
|
|
'kodkerja',
|
|
'kodugama',
|
|
'kodstatus',
|
|
'kodbank',
|
|
'noakaun',
|
|
'nota' ,
|
|
'teller',
|
|
'pelulus',
|
|
't_ubah',
|
|
'm_ubah',
|
|
'aktif',
|
|
'yuranahli',
|
|
'tujuangadai',
|
|
'kodkerjabaru',
|
|
'nopelangganlama',
|
|
'tagperingatan',
|
|
'kumpulan',
|
|
'telefon2',
|
|
'tagpelanggan'
|
|
];
|
|
|
|
/**
|
|
* The attributes excluded from the model's JSON form.
|
|
*
|
|
* @var array
|
|
*/
|
|
// protected $hidden = [];
|
|
|
|
/**
|
|
* Set the keys for a save update query.
|
|
*
|
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
|
* @return \Illuminate\Database\Eloquent\Builder
|
|
*/
|
|
protected function setKeysForSaveQuery(Builder $query)
|
|
{
|
|
$keys = $this->getKeyName();
|
|
if(!is_array($keys)){
|
|
return parent::setKeysForSaveQuery($query);
|
|
}
|
|
|
|
foreach($keys as $keyName){
|
|
$query->where($keyName, '=', $this->getKeyForSaveQuery($keyName));
|
|
}
|
|
|
|
return $query;
|
|
}
|
|
|
|
/**
|
|
* Get the primary key value for a save query.
|
|
*
|
|
* @param mixed $keyName
|
|
* @return mixed
|
|
*/
|
|
protected function getKeyForSaveQuery($keyName = null)
|
|
{
|
|
if(is_null($keyName)){
|
|
$keyName = $this->getKeyName();
|
|
}
|
|
|
|
if (isset($this->original[$keyName])) {
|
|
return $this->original[$keyName];
|
|
}
|
|
|
|
return $this->getAttribute($keyName);
|
|
}
|
|
} |