2016-05-15 05:08:41 -05:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* UnfinishedJournal.php
|
|
|
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
|
|
|
*
|
2016-10-04 23:52:15 -05: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-05-15 05:08:41 -05:00
|
|
|
*/
|
|
|
|
|
2017-04-09 00:44:22 -05:00
|
|
|
declare(strict_types=1);
|
2016-05-15 05:08:41 -05:00
|
|
|
|
|
|
|
namespace FireflyIII\Support\Binder;
|
|
|
|
|
|
|
|
use FireflyIII\Models\TransactionJournal;
|
|
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class Date
|
|
|
|
*
|
|
|
|
* @package FireflyIII\Support\Binder
|
|
|
|
*/
|
|
|
|
class UnfinishedJournal implements BinderInterface
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param $value
|
|
|
|
* @param $route
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public static function routeBinder($value, $route): TransactionJournal
|
|
|
|
{
|
2016-09-16 05:07:45 -05:00
|
|
|
if (auth()->check()) {
|
2016-05-15 05:08:41 -05:00
|
|
|
$object = TransactionJournal::where('transaction_journals.id', $value)
|
|
|
|
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
|
|
|
->where('completed', 0)
|
2016-09-16 05:15:58 -05:00
|
|
|
->where('user_id', auth()->user()->id)->first(['transaction_journals.*']);
|
2016-05-15 05:08:41 -05:00
|
|
|
if ($object) {
|
|
|
|
return $object;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new NotFoundHttpException;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|