firefly-iii/app/Models/ExportJob.php

69 lines
1.4 KiB
PHP
Raw Normal View History

2016-02-04 10:14:59 -06:00
<?php
/**
* ExportJob.php
2016-04-01 09:44:46 -05:00
* Copyright (C) 2016 thegrumpydictator@gmail.com
2016-02-04 10:14:59 -06:00
*
* 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.
2016-02-04 10:14:59 -06:00
*/
declare(strict_types=1);
2016-02-04 10:14:59 -06:00
namespace FireflyIII\Models;
use Illuminate\Database\Eloquent\Model;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
2016-11-18 13:06:08 -06:00
/**
* Class ExportJob
*
* @package FireflyIII\Models
*/
2016-02-04 10:14:59 -06:00
class ExportJob extends Model
{
2016-12-24 10:36:51 -06:00
/** @var array */
protected $casts
= [
'created_at' => 'date',
'updated_at' => 'date',
];
/** @var array */
protected $dates = ['created_at', 'updated_at'];
2016-02-04 10:14:59 -06:00
/**
* @param $value
*
* @return mixed
* @throws NotFoundHttpException
*/
public static function routeBinder($value)
{
2016-09-16 05:07:45 -05:00
if (auth()->check()) {
2016-09-16 05:15:58 -05:00
$model = self::where('key', $value)->where('user_id', auth()->user()->id)->first();
2016-02-04 10:14:59 -06:00
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');
}
}