| 1 |
<?php |
| 2 |
|
| 3 |
namespace Booktics\Models; |
| 4 |
|
| 5 |
use Booktics\Abstracts\Booktics_Database; |
| 6 |
use Booktics\Abstracts\User_Model; |
| 7 |
|
| 8 |
class Customer_Model extends User_Model { |
| 9 |
/** |
| 10 |
* Store specific user role |
| 11 |
* |
| 12 |
* @var string |
| 13 |
*/ |
| 14 |
protected $role = 'booktics_customer'; |
| 15 |
|
| 16 |
/** |
| 17 |
* Store specific meta prefix |
| 18 |
* |
| 19 |
* @var string |
| 20 |
*/ |
| 21 |
protected $meta_prefix = '_customer_'; |
| 22 |
|
| 23 |
/** |
| 24 |
* Store user data |
| 25 |
* |
| 26 |
* @var array |
| 27 |
*/ |
| 28 |
protected $fillable = [ |
| 29 |
'id' => '', |
| 30 |
'display_name' => '', |
| 31 |
'first_name' => '', |
| 32 |
'last_name' => '', |
| 33 |
'user_email' => '', |
| 34 |
'image' => '', |
| 35 |
'user_login' => '', |
| 36 |
'phone' => '', |
| 37 |
'role' => [], |
| 38 |
'status' => '', |
| 39 |
'user_registered' => '', |
| 40 |
'total_booking' => '', |
| 41 |
'total_amount' => '', |
| 42 |
]; |
| 43 |
|
| 44 |
/** |
| 45 |
* Display name attribute |
| 46 |
* |
| 47 |
* @param $customer |
| 48 |
* |
| 49 |
* @return string |
| 50 |
*/ |
| 51 |
public function get_display_name_attribute( $customer ) { |
| 52 |
return $customer->first_name . ' ' . $customer->last_name; |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* email attribute |
| 57 |
* |
| 58 |
* @param $customer |
| 59 |
* |
| 60 |
* @return string |
| 61 |
*/ |
| 62 |
public function get_email_attribute( $customer ) { |
| 63 |
return $customer->email ?? $customer->user_email; |
| 64 |
} |
| 65 |
} |