37 lines
918 B
PHP
37 lines
918 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Brand extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = "brands";
|
|
|
|
public function services() {
|
|
return $this->hasMany('App\Models\Service', 'brand_id');
|
|
}
|
|
|
|
public function customer_infos() {
|
|
return $this->hasMany('App\Models\CustomerInfos', 'brand_id');
|
|
}
|
|
|
|
public function services_stats() {
|
|
return $this->hasMany('App\Models\ServiceStat', 'brand_id');
|
|
}
|
|
|
|
public function single_optins() {
|
|
return $this->hasMany('App\Models\SingleOptin', 'brand_id');
|
|
}
|
|
|
|
public function getAccountsAttribute(){
|
|
return $this->customer_infos()->count();
|
|
}
|
|
|
|
public function getTotalOptinsAttribute(){
|
|
return $this->customer_infos()->where('opt_in', 1)->count() + $this->single_optins()->count();
|
|
}
|
|
}
|