| Server IP : 77.68.64.20 / Your IP : 216.73.217.31 Web Server : Apache System : Linux hp3-wp-1011317.hostingp3.local 3.10.0-1160.144.1.el7.tuxcare.els8.x86_64 #1 SMP Sun Jul 5 17:25:39 UTC 2026 x86_64 User : csh2392878 ( 2033753) PHP Version : 8.3.30 Disable Function : shell_exec,exec,system,popen,set_time_limit MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/domains/vol1/746/2880746/user/htdocs/wp-content/plugins/booknetic/app/Models/ |
Upload File : |
<?php
namespace BookneticApp\Models;
use BookneticApp\Providers\Core\Permission;
use BookneticApp\Providers\DB\Model;
use BookneticApp\Providers\DB\MultiTenant;
use BookneticApp\Providers\DB\QueryBuilder;
/**
* @property-read int $id
* @property-read int $user_id
* @property-read string $first_name
* @property-read string $last_name
* @property-read string $phone_number
* @property-read string $email
* @property-read string $birthdate
* @property-read string $notes
* @property-read string $profile_image
* @property-read string $gender
* @property-read int $tenant_id
* @property-read int $created_by
* @property-read int $created_at
* @property-read string $full_name
* @property-read bool $category_id
*/
class Customer extends Model
{
use MultiTenant {
booted as private tenantBoot;
}
public static $relations = [
'category' => [ CustomerCategory::class, 'id', 'category_id' ]
];
/**
* @param self $customer
*
* @return string
*/
public function getFullNameAttribute($customer)
{
return $customer->first_name . ' ' . $customer->last_name;
}
public static function my()
{
if (Permission::isAdministrator() || Permission::isSuperAdministrator()) {
return new static();
}
if (apply_filters('bkntc_query_builder_global_scope', false, 'customers')) {
return new static();
}
$subQuery = Appointment::query()->select('customer_id', true);
return self::query()->where(function ($query) use ($subQuery) {
$query->where('created_by', Permission::userId())->orWhere('id', 'in', $subQuery);
});
}
public static function booted()
{
self::tenantBoot();
self::addGlobalScope('my_customers', function (QueryBuilder $builder, $queryType) {
if (! Permission::isBackEnd() || Permission::isAdministrator()) {
return;
}
if (apply_filters('bkntc_query_builder_global_scope', false, 'customers')) {
return;
}
$subQuery = Appointment::query()->select('customer_id', true);
$builder->where(function ($query) use ($subQuery) {
$query->where(Customer::getField('created_by'), Permission::userId())->orWhere(Customer::getField('id'), 'in', $subQuery);
});
});
}
}