/** * @return array A list of available exports for this user */ protected function getUserImportables() { $_result = []; /** @noinspection PhpUndefinedFieldInspection */ $_rows = Snapshot::byUserId(\Auth::user()->id)->orderBy('create_date', 'desc')->get(['id', 'instance_id', 'snapshot_id_text']); if (!empty($_rows)) { /** @var Snapshot[] $_rows */ foreach ($_rows as $_row) { list($_date, $_instanceName) = explode('.', $_row->snapshot_id_text, 2); try { // Find instance, dead or alive! $_instance = $this->_locateInstance($_instanceName); $_result[] = ['id' => $_row->id, 'name' => $_row->snapshot_id_text, 'instance-id' => $_instance ? $_instance->instance_id_text : 'unknown', 'export-date' => Carbon::create($_row->create_date)->toFormattedDateString(), 'instance-name' => $_instanceName]; } catch (ModelNotFoundException $_ex) { // ignored on purpose } } } return $_result; }