2016-04-23 09:33:54 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* JournalList.php
|
|
|
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
|
|
|
*
|
2016-10-05 06:52:15 +02: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-04-23 09:33:54 +02:00
|
|
|
*/
|
|
|
|
|
2016-05-20 12:41:23 +02:00
|
|
|
declare(strict_types = 1);
|
2016-04-23 09:33:54 +02:00
|
|
|
|
2016-05-20 12:41:23 +02:00
|
|
|
namespace FireflyIII\Support\Binder;
|
2016-04-23 09:33:54 +02:00
|
|
|
|
|
|
|
use FireflyIII\Models\TransactionJournal;
|
|
|
|
use Illuminate\Support\Collection;
|
|
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class JournalList
|
|
|
|
*
|
|
|
|
* @package FireflyIII\Support\Binder
|
|
|
|
*/
|
|
|
|
class JournalList implements BinderInterface
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param $value
|
|
|
|
* @param $route
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public static function routeBinder($value, $route): Collection
|
|
|
|
{
|
2016-09-16 12:07:45 +02:00
|
|
|
if (auth()->check()) {
|
2016-04-23 09:33:54 +02:00
|
|
|
$ids = explode(',', $value);
|
|
|
|
/** @var \Illuminate\Support\Collection $object */
|
|
|
|
$object = TransactionJournal::whereIn('transaction_journals.id', $ids)
|
|
|
|
->expanded()
|
2016-09-16 12:15:58 +02:00
|
|
|
->where('transaction_journals.user_id', auth()->user()->id)
|
2017-03-04 07:18:35 +01:00
|
|
|
->get([
|
|
|
|
'transaction_journals.*',
|
|
|
|
'transaction_types.type AS transaction_type_type',
|
|
|
|
'transaction_currencies.code AS transaction_currency_code',
|
|
|
|
]);
|
2016-04-23 09:33:54 +02:00
|
|
|
|
|
|
|
if ($object->count() > 0) {
|
|
|
|
return $object;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
throw new NotFoundHttpException;
|
|
|
|
}
|
|
|
|
}
|