Viewing file: Customer.php (2.85 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Laravel\Sanctum\HasApiTokens;
class Customer extends Authenticatable { use HasFactory, Notifiable, HasApiTokens;
/** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'first_name', 'last_name', 'email', 'password','type', 'status', 'email_verified_at','added_by', ];
/** * The attributes that should be hidden for arrays. * * @var array */ protected $hidden = [ 'password', 'remember_token', ];
/** * The attributes that should be cast to native types. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', ];
protected $dates = ['created_at', 'updated_at'];
public function getFullNameAttribute() { return "{$this->first_name} {$this->last_name}"; }
public function setPasswordAttribute($value) { $this->attributes['password'] = bcrypt($value); }
public function getStatusAttribute($value) { return ucfirst($value); }
public function admin() { return $this->belongsTo(User::class, 'admin_id')->withDefault(); }
public function numbers() { return $this->hasMany(CustomerNumber::class, 'customer_id', 'id'); }
public function settings() { return $this->hasMany(Settings::class, 'admin_id', 'id'); }
public function contacts() { return $this->hasMany(Contact::class)->orderByDesc('created_at'); }
public function groups() { return $this->hasMany(Group::class)->orderByDesc('created_at'); }
public function active_groups() { return $this->groups()->where('status', 'active'); }
public function messages() { return $this->hasMany(Message::class); } public function keywords() { return $this->hasMany(Keyword::class); }
public function campaings() { return $this->hasMany(Campaign::class); }
public function from_groups(){ return $this->hasMany(FromGroup::class, 'customer_id', 'id'); }
public function chat_responses(){ return $this->hasMany(ChatResponse::class, 'customer_id', 'id'); }
public function labels(){ return $this->hasMany(Label::class,'customer_id', 'id'); }
public function exceptions(){ return $this->hasMany(Exception::class, 'customer_id', 'id'); }
public function customers(){ return $this->hasMany(Customer::class,'admin_id', 'id'); }
public function gateways(){ return $this->hasMany(DynamicGateway::class,'customer_id', 'id'); }
}
|