68 lines
1.4 KiB
PHP
Executable File
68 lines
1.4 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class LoyaltyCardSignUp extends Model
|
|
{
|
|
/**
|
|
* Table name of model
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $table = 'loyalty_card_signup';
|
|
|
|
/**
|
|
* Primary key field name of table
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $primaryKey = 'lcard_s_id';
|
|
|
|
/**
|
|
* Additional fields from other connected tables
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $appends = [];
|
|
|
|
/**
|
|
* The attributes that should be hidden for arrays.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $hidden = [];
|
|
|
|
/**
|
|
* The attributes that should be mutated to dates.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $dates = ['created_at','updated_at','birthdate'];
|
|
|
|
|
|
public function codeCardType()
|
|
{
|
|
return $this->hasOne('App\CodeCardType','cardtype_id','cardtype_id');
|
|
}
|
|
|
|
|
|
public function idNumberType()
|
|
{
|
|
return $this->hasOne('App\IDNumberType','idnt_id','idnt_id');
|
|
}
|
|
|
|
public function scopeSort($query, $field, $order)
|
|
{
|
|
switch ($field) {
|
|
case 'card_type':
|
|
$query->leftJoin('code_card_type', 'loyalty_card.cardtype_id', '=','code_card_type.cardtype_id');
|
|
$query->orderBy('code_card_type.code', $order);
|
|
break;
|
|
default:
|
|
return $query->orderBy($field, $order);
|
|
}
|
|
}
|
|
}
|