public function location() { //get location from pivot table (vks_store_location) $location = App::$instance->capsule->connection('coreCaDb')->table('vks_store_location')->where('vks_id', $this->id)->first(['location']); //try find it in attendance table // dump(); $tryGetAtt = !AttendanceNew_controller::isLocationString($location['location']) ? CAAttendance::find($location['location']) : false; // dump($tryGetAtt); if (!$tryGetAtt) { return $this->hasOne('CACustomLocation', 'vks_id', 'id'); } else { $this->location = $location['location']; return $this->hasOne('CAAttendance', 'id', 'location'); } }
public function getStackArray($stackName) { $result = []; $c = 0; if (isset($_COOKIE[$stackName]) && !empty($_COOKIE[$stackName])) { foreach (explode("@@DELIM@@", $_COOKIE[$stackName]) as $id) { if (!AttendanceNew_controller::isLocationString($id)) { $result[$c]['path'] = self::fullParentInfo($id); $result[$c]['pathString'] = $this->makePathString(self::fullParentInfo($id)); } else { $result[$c]['pathString'] = $id; } $result[$c]['id'] = $id; $c++; } } return $result; }