check()) { $model = self::where('key', $value)->where('user_id', auth()->user()->id)->first(); if (!is_null($model)) { return $model; } } throw new NotFoundHttpException; } /** * @param int $count */ public function addStepsDone(int $count) { $status = $this->extended_status; $status['steps_done'] += $count; $this->extended_status = $status; $this->save(); } /** * @param int $count */ public function addTotalSteps(int $count) { $status = $this->extended_status; $status['total_steps'] += $count; $this->extended_status = $status; $this->save(); } /** * @param $status */ public function change($status) { $this->status = $status; $this->save(); } /** * @param $value * * @return mixed */ public function getConfigurationAttribute($value) { if (strlen($value) == 0) { return []; } return json_decode($value, true); } /** * @param $value * * @return mixed */ public function getExtendedStatusAttribute($value) { if (strlen($value) == 0) { return []; } return json_decode($value, true); } /** * @param $value */ public function setConfigurationAttribute($value) { $this->attributes['configuration'] = json_encode($value); } /** * @param $value */ public function setExtendedStatusAttribute($value) { $this->attributes['extended_status'] = json_encode($value); } /** * @param $value */ public function setStatusAttribute(string $value) { if (in_array($value, $this->validStatus)) { $this->attributes['status'] = $value; } } /** * @return string */ public function uploadFileContents(): string { $fileName = $this->key . '.upload'; $disk = Storage::disk('upload'); $encryptedContent = $disk->get($fileName); $content = Crypt::decrypt($encryptedContent); return $content; } /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function user() { return $this->belongsTo('FireflyIII\User'); } }