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'); } }
<p> С рабочих мест в ЦА: <span class="label label-as-badge label-default"><?php echo $vks->CaInPlaceParticipantCount->participants_count; ?> </span> </p> <p> Заявленные ТБ: <ol> <?php foreach ($vks->CaIdParticipants as $ca_id) { ?> <li><span class="glyphicon glyphicon-facetime-video text-success"></span> <?php echo CAAttendance::find($ca_id->ca_att_id)->name; ?> </li> <?php } ?> </ol> </p> <?php } else { ?> <p>Не определено</p> <?php } ?> </td>