71 lines
1.3 KiB
PHP
71 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Admin extends Model
|
|
{
|
|
|
|
/**
|
|
* Table name of model
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $table = 'admin';
|
|
|
|
/**
|
|
* Primary key field name of table
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $primaryKey = 'admin_id';
|
|
|
|
/**
|
|
* Additional fields from other connected tables
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $appends = [];
|
|
|
|
/**
|
|
* The attributes that should be hidden for arrays.
|
|
*
|
|
* @var array
|
|
*/
|
|
|
|
protected $hidden = ['password'];
|
|
|
|
/**
|
|
* The attributes that should be mutated to dates.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $dates = ['created_at','updated_at'];
|
|
|
|
public function getFullNameAttribute($key)
|
|
{
|
|
return ucwords($this->firstname." ".$this->lastname);
|
|
}
|
|
|
|
public function setFullNameAttribute($key)
|
|
{
|
|
return ucwords($this->firstname." ".$this->lastname);
|
|
}
|
|
|
|
public function setFirstnameAttribute($value)
|
|
{
|
|
return $this->attributes['firstname'] = ucwords($value);
|
|
}
|
|
|
|
public function setLastnameAttribute($value)
|
|
{
|
|
return $this->attributes['lastname'] = ucwords($value);
|
|
}
|
|
|
|
public function user()
|
|
{
|
|
return $this->hasOne('App\User','username',"username");
|
|
}
|
|
}
|