mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-27 17:31:09 -06:00
New model for export.
This commit is contained in:
parent
902f310eb0
commit
d7a66f6782
64
app/Models/ExportJob.php
Normal file
64
app/Models/ExportJob.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* ExportJob.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Auth;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Class ExportJob
|
||||
*
|
||||
* @package FireflyIII
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $user_id
|
||||
* @property string $key
|
||||
* @property string $status
|
||||
* @property-read \FireflyIII\User $user
|
||||
*/
|
||||
class ExportJob extends Model
|
||||
{
|
||||
/**
|
||||
* @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();
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('FireflyIII\User');
|
||||
}
|
||||
}
|
@ -29,6 +29,7 @@ use Zizaco\Entrust\Traits\EntrustUserTrait;
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Role[] $roles
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\RuleGroup[] $ruleGroups
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Rule[] $rules
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\ExportJob[] $exportjobs
|
||||
*/
|
||||
class User extends Authenticatable
|
||||
{
|
||||
@ -97,6 +98,14 @@ class User extends Authenticatable
|
||||
return $this->hasMany('FireflyIII\Models\Category');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function exportjobs()
|
||||
{
|
||||
return $this->hasMany('FireflyIII\Models\ExportJob');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user