2022-03-05 16:02:12 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2022-05-15 08:49:54 +02:00
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
2022-03-05 16:02:12 +01:00
|
|
|
|
|
|
|
class Reseller extends Model
|
|
|
|
{
|
|
|
|
use HasFactory;
|
|
|
|
|
|
|
|
protected $table = 'reseller_hosting';
|
|
|
|
|
2022-07-22 15:49:18 +02:00
|
|
|
protected $keyType = 'string';
|
|
|
|
|
2022-03-05 16:02:12 +01:00
|
|
|
protected $fillable = ['id', 'active', 'accounts', 'main_domain', 'has_dedicated_ip', 'ip', 'reseller_type', 'provider_id', 'location_id', 'bandwidth', 'disk', 'disk_type', 'disk_as_gb', 'domains_limit', 'subdomains_limit', 'ftp_limit', 'email_limit', 'db_limit', 'was_promo', 'owned_since'];
|
|
|
|
|
|
|
|
public $incrementing = false;
|
2022-05-15 08:49:54 +02:00
|
|
|
|
2022-07-19 07:55:10 +02:00
|
|
|
public static function allResellerHosting()
|
|
|
|
{//All reseller hosting and relationships (no using joins)
|
|
|
|
return Cache::remember("all_reseller", now()->addMonth(1), function () {
|
|
|
|
return Reseller::with(['location', 'provider', 'price', 'ips', 'labels', 'labels.label'])->get();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function resellerHosting(string $shared_id)
|
|
|
|
{//Single reseller hosting and relationships (no using joins)
|
|
|
|
return Cache::remember("reseller_hosting.$shared_id", now()->addMonth(1), function () use ($shared_id) {
|
|
|
|
return Reseller::where('id', $shared_id)
|
|
|
|
->with(['location', 'provider', 'price', 'ips', 'labels', 'labels.label'])->get();
|
|
|
|
});
|
|
|
|
}
|
2022-07-22 15:49:18 +02:00
|
|
|
|
2022-07-19 07:55:10 +02:00
|
|
|
public function ips()
|
|
|
|
{
|
|
|
|
return $this->hasMany(IPs::class, 'service_id', 'id');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function location()
|
2022-05-15 08:49:54 +02:00
|
|
|
{
|
2022-07-19 07:55:10 +02:00
|
|
|
return $this->hasOne(Locations::class, 'id', 'location_id');
|
2022-05-15 08:49:54 +02:00
|
|
|
}
|
|
|
|
|
2022-07-19 07:55:10 +02:00
|
|
|
public function provider()
|
2022-05-15 08:49:54 +02:00
|
|
|
{
|
2022-07-19 07:55:10 +02:00
|
|
|
return $this->hasOne(Providers::class, 'id', 'provider_id');
|
2022-05-15 08:49:54 +02:00
|
|
|
}
|
|
|
|
|
2022-07-19 07:55:10 +02:00
|
|
|
public function price()
|
2022-05-15 08:49:54 +02:00
|
|
|
{
|
2022-07-19 07:55:10 +02:00
|
|
|
return $this->hasOne(Pricing::class, 'service_id', 'id');
|
|
|
|
}
|
2022-05-15 08:49:54 +02:00
|
|
|
|
2022-07-19 07:55:10 +02:00
|
|
|
public function labels()
|
|
|
|
{
|
|
|
|
return $this->hasMany(LabelsAssigned::class, 'service_id', 'id');
|
2022-05-15 08:49:54 +02:00
|
|
|
}
|
|
|
|
|
2022-03-05 16:02:12 +01:00
|
|
|
}
|