orderBy($array[0], $array[1]); } }); } public static function allSharedHosting() {//All shared hosting and relationships (no using joins) return Cache::remember("all_shared", now()->addMonth(1), function () { return Shared::with(['location', 'provider', 'price', 'ips', 'labels', 'labels.label'])->get(); }); } public static function sharedHosting(string $shared_id) {//Single shared hosting and relationships (no using joins) return Cache::remember("shared_hosting.$shared_id", now()->addMonth(1), function () use ($shared_id) { return Shared::where('id', $shared_id) ->with(['location', 'provider', 'price', 'ips', 'labels', 'labels.label'])->first(); }); } public function ips() { return $this->hasMany(IPs::class, 'service_id', 'id'); } public function location() { return $this->hasOne(Locations::class, 'id', 'location_id'); } public function provider() { return $this->hasOne(Providers::class, 'id', 'provider_id'); } public function price() { if (in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) { return $this->hasOne(Pricing::class, 'service_id', 'id')->orderBy(Settings::orderByProcess(Session::get('sort_on'))[0], Settings::orderByProcess(Session::get('sort_on'))[1]); } return $this->hasOne(Pricing::class, 'service_id', 'id'); } public function labels() { return $this->hasMany(LabelsAssigned::class, 'service_id', 'id'); } }