. */ declare(strict_types=1); namespace FireflyIII\Models; use FireflyIII\User; use Illuminate\Database\Eloquent\Model; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Class ImportJob. * * @property array $transactions * @property array $configuration * @property User $user * @property int $user_id * @property string $status * @property string $stage */ class ImportJob extends Model { /** * The attributes that should be casted to native types. * * @var array */ protected $casts = [ 'created_at' => 'datetime', 'updated_at' => 'datetime', 'configuration' => 'array', 'extended_status' => 'array', 'transactions' => 'array', 'errors' => 'array', ]; /** @var array */ protected $fillable = ['key', 'user_id', 'file_type', 'provider', 'status', 'stage', 'configuration', 'extended_status', 'transactions', 'errors']; /** * @param $value * * @return mixed * * @throws NotFoundHttpException */ public static function routeBinder(string $value): ImportJob { if (auth()->check()) { $key = trim($value); $importJob = auth()->user()->importJobs()->where('key', $key)->first(); if (null !== $importJob) { return $importJob; } } throw new NotFoundHttpException; } /** * @codeCoverageIgnore * @return \Illuminate\Database\Eloquent\Relations\MorphMany */ public function attachments() { return $this->morphMany(Attachment::class, 'attachable'); } /** * @codeCoverageIgnore * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function tag() { return $this->belongsTo(Tag::class); } /** * @codeCoverageIgnore * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function user() { return $this->belongsTo(User::class); } }