firefly-iii/app/Models/ExportJob.php
2017-08-18 15:32:11 +02:00

72 lines
1.5 KiB
PHP

<?php
/**
* ExportJob.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
*/
declare(strict_types=1);
namespace FireflyIII\Models;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Class ExportJob
*
* @property User $user
*
* @package FireflyIII\Models
*/
class ExportJob extends Model
{
/** @var array */
protected $casts
= [
'created_at' => 'date',
'updated_at' => 'date',
];
/** @var array */
protected $dates = ['created_at', 'updated_at'];
/**
* @param $value
*
* @return mixed
* @throws NotFoundHttpException
*/
public static function routeBinder($value)
{
if (auth()->check()) {
$model = self::where('key', $value)->where('user_id', auth()->user()->id)->first();
if (!is_null($model)) {
return $model;
}
}
throw new NotFoundHttpException;
}
/**
* @param $status
*/
public function change($status)
{
$this->status = $status;
$this->save();
}
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo('FireflyIII\User');
}
}