2020-12-01 17:02:10 +01:00
|
|
|
<?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');
|
|
|
|
|
}
|
2020-12-02 10:08:27 +01:00
|
|
|
|
|
|
|
|
public function single_optins() {
|
|
|
|
|
return $this->hasMany('App\Models\SingleOptin', 'brand_id');
|
|
|
|
|
}
|
2021-03-08 11:37:54 +01:00
|
|
|
|
|
|
|
|
public function getAccountsAttribute(){
|
|
|
|
|
return $this->customer_infos()->count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getTotalOptinsAttribute(){
|
|
|
|
|
return $this->customer_infos()->where('opt_in', 1)->count() + $this->single_optins()->count();
|
|
|
|
|
}
|
2020-12-01 17:02:10 +01:00
|
|
|
}
|