/** * @param bool $createIfNull * * @return Filesystem */ public function getStorage($createIfNull = true) { // Use requested file system if one... if (null === ($_storage = $this->get('storage')) && $createIfNull) { $_instance = $this->getInstance(); $_user = $_instance->user; if (empty($_user)) { try { $_user = User::findOrFail($_instance->user_id); } catch (ModelNotFoundException $_ex) { \Log::error('Attempt to create an instance for a non-existent user_id: ' . $_instance->user_id); throw new \RuntimeException('Invalid user assigned to instance.'); } } InstanceStorage::buildStorageMap($_user->storage_id_text); $_storage = $_instance->getStorageRootMount(); $this->setStorage($_storage); } return $_storage; }
/** * @param int $userId * * @return User */ protected static function findUser($userId) { return User::findOrFail($userId); }