mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Updated export job repository
This commit is contained in:
parent
ca33bea6b7
commit
b4f1bbf793
50
app/Providers/ExportJobServiceProvider.php
Normal file
50
app/Providers/ExportJobServiceProvider.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace FireflyIII\Providers;
|
||||||
|
|
||||||
|
use Auth;
|
||||||
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
|
use Illuminate\Foundation\Application;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ExportJobServiceProvider
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Providers
|
||||||
|
*/
|
||||||
|
class ExportJobServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Bootstrap the application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$this->app->bind(
|
||||||
|
'FireflyIII\Repositories\ExportJob\ExportJobRepositoryInterface',
|
||||||
|
function (Application $app, array $arguments) {
|
||||||
|
if (!isset($arguments[0]) && Auth::check()) {
|
||||||
|
return app('FireflyIII\Repositories\ExportJob\ExportJobRepository', [Auth::user()]);
|
||||||
|
} else {
|
||||||
|
if (!isset($arguments[0]) && !Auth::check()) {
|
||||||
|
throw new FireflyException('There is no user present.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return app('FireflyIII\Repositories\ExportJob\ExportJobRepository', $arguments);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
@ -90,7 +90,6 @@ class FireflyServiceProvider extends ServiceProvider
|
|||||||
$this->app->bind('FireflyIII\Repositories\Tag\TagRepositoryInterface', 'FireflyIII\Repositories\Tag\TagRepository');
|
$this->app->bind('FireflyIII\Repositories\Tag\TagRepositoryInterface', 'FireflyIII\Repositories\Tag\TagRepository');
|
||||||
$this->app->bind('FireflyIII\Repositories\Rule\RuleRepositoryInterface', 'FireflyIII\Repositories\Rule\RuleRepository');
|
$this->app->bind('FireflyIII\Repositories\Rule\RuleRepositoryInterface', 'FireflyIII\Repositories\Rule\RuleRepository');
|
||||||
$this->app->bind('FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface', 'FireflyIII\Repositories\RuleGroup\RuleGroupRepository');
|
$this->app->bind('FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface', 'FireflyIII\Repositories\RuleGroup\RuleGroupRepository');
|
||||||
$this->app->bind('FireflyIII\Repositories\ExportJob\ExportJobRepositoryInterface', 'FireflyIII\Repositories\ExportJob\ExportJobRepository');
|
|
||||||
$this->app->bind('FireflyIII\Support\Search\SearchInterface', 'FireflyIII\Support\Search\Search');
|
$this->app->bind('FireflyIII\Support\Search\SearchInterface', 'FireflyIII\Support\Search\Search');
|
||||||
|
|
||||||
// CSV import
|
// CSV import
|
||||||
|
@ -10,10 +10,11 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Repositories\ExportJob;
|
namespace FireflyIII\Repositories\ExportJob;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Models\ExportJob;
|
use FireflyIII\Models\ExportJob;
|
||||||
|
use FireflyIII\User;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ExportJobRepository
|
* Class ExportJobRepository
|
||||||
@ -22,6 +23,19 @@ use Illuminate\Support\Str;
|
|||||||
*/
|
*/
|
||||||
class ExportJobRepository implements ExportJobRepositoryInterface
|
class ExportJobRepository implements ExportJobRepositoryInterface
|
||||||
{
|
{
|
||||||
|
/** @var User */
|
||||||
|
private $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BillRepository constructor.
|
||||||
|
*
|
||||||
|
* @param User $user
|
||||||
|
*/
|
||||||
|
public function __construct(User $user)
|
||||||
|
{
|
||||||
|
Log::debug('Constructed bill repository for user #' . $user->id . ' (' . $user->email . ')');
|
||||||
|
$this->user = $user;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
@ -57,7 +71,7 @@ class ExportJobRepository implements ExportJobRepositoryInterface
|
|||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
$exportJob = new ExportJob;
|
$exportJob = new ExportJob;
|
||||||
$exportJob->user()->associate(Auth::user());
|
$exportJob->user()->associate($this->user);
|
||||||
/*
|
/*
|
||||||
* In theory this random string could give db error.
|
* In theory this random string could give db error.
|
||||||
*/
|
*/
|
||||||
@ -75,7 +89,7 @@ class ExportJobRepository implements ExportJobRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function findByKey(string $key)
|
public function findByKey(string $key)
|
||||||
{
|
{
|
||||||
return Auth::user()->exportJobs()->where('key', $key)->first();
|
return $this->user->exportJobs()->where('key', $key)->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user