mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Would be nice to remove the references as well...
This commit is contained in:
parent
0f09a9db4d
commit
e69e6c1ce8
@ -58,9 +58,9 @@ class Attachment extends Model
|
||||
*/
|
||||
public static function routeBinder(string $value): Attachment
|
||||
{
|
||||
if ($guard->check()) {
|
||||
if (auth()->check()) {
|
||||
$attachmentId = intval($value);
|
||||
$attachment = $guard->user()->attachments()->find($attachmentId);
|
||||
$attachment = auth()->user()->attachments()->find($attachmentId);
|
||||
if (!is_null($attachment)) {
|
||||
return $attachment;
|
||||
}
|
||||
|
@ -90,9 +90,9 @@ class Budget extends Model
|
||||
*/
|
||||
public static function routeBinder(string $value): Budget
|
||||
{
|
||||
if ($guard->check()) {
|
||||
if (auth()->check()) {
|
||||
$budgetId = intval($value);
|
||||
$budget = $guard->user()->budgets()->find($budgetId);
|
||||
$budget = auth()->user()->budgets()->find($budgetId);
|
||||
if (!is_null($budget)) {
|
||||
return $budget;
|
||||
}
|
||||
|
@ -51,11 +51,11 @@ class BudgetLimit extends Model
|
||||
*/
|
||||
public static function routeBinder(string $value): BudgetLimit
|
||||
{
|
||||
if ($guard->check()) {
|
||||
if (auth()->check()) {
|
||||
$budgetLimitId = intval($value);
|
||||
$budgetLimit = self::where('budget_limits.id', $budgetLimitId)
|
||||
->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')
|
||||
->where('budgets.user_id', $guard->user()->id)
|
||||
->where('budgets.user_id', auth()->user()->id)
|
||||
->first(['budget_limits.*']);
|
||||
if (!is_null($budgetLimit)) {
|
||||
return $budgetLimit;
|
||||
|
@ -89,9 +89,9 @@ class Category extends Model
|
||||
*/
|
||||
public static function routeBinder(string $value): Category
|
||||
{
|
||||
if ($guard->check()) {
|
||||
if (auth()->check()) {
|
||||
$categoryId = intval($value);
|
||||
$category = $guard->user()->categories()->find($categoryId);
|
||||
$category = auth()->user()->categories()->find($categoryId);
|
||||
if (!is_null($category)) {
|
||||
return $category;
|
||||
}
|
||||
|
@ -50,9 +50,9 @@ class ExportJob extends Model
|
||||
*/
|
||||
public static function routeBinder(string $value): ExportJob
|
||||
{
|
||||
if ($guard->check()) {
|
||||
if (auth()->check()) {
|
||||
$key = trim($value);
|
||||
$exportJob = $guard->user()->exportJobs()->where('key', $key)->first();
|
||||
$exportJob = auth()->user()->exportJobs()->where('key', $key)->first();
|
||||
if (null !== $exportJob) {
|
||||
return $exportJob;
|
||||
}
|
||||
|
@ -67,9 +67,9 @@ class ImportJob extends Model
|
||||
*/
|
||||
public static function routeBinder(string $value): ImportJob
|
||||
{
|
||||
if ($guard->check()) {
|
||||
if (auth()->check()) {
|
||||
$key = trim($value);
|
||||
$importJob = $guard->user()->importJobs()->where('key', $key)->first();
|
||||
$importJob = auth()->user()->importJobs()->where('key', $key)->first();
|
||||
if (null !== $importJob) {
|
||||
// must have valid status:
|
||||
if (!in_array($importJob->status, $importJob->validStatus)) {
|
||||
|
@ -56,7 +56,7 @@ class LinkType extends Model
|
||||
*/
|
||||
public static function routeBinder(string $value): LinkType
|
||||
{
|
||||
if ($guard->check()) {
|
||||
if (auth()->check()) {
|
||||
$linkTypeId = intval($value);
|
||||
$linkType = self::find($linkTypeId);
|
||||
if (null !== $linkType) {
|
||||
|
@ -67,11 +67,11 @@ class PiggyBank extends Model
|
||||
*/
|
||||
public static function routeBinder(string $value): PiggyBank
|
||||
{
|
||||
if ($guard->check()) {
|
||||
if (auth()->check()) {
|
||||
$piggyBankId = intval($value);
|
||||
$piggyBank = self::where('piggy_banks.id', $piggyBankId)
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')
|
||||
->where('accounts.user_id', $guard->user()->id)->first(['piggy_banks.*']);
|
||||
->where('accounts.user_id', auth()->user()->id)->first(['piggy_banks.*']);
|
||||
if (!is_null($piggyBank)) {
|
||||
return $piggyBank;
|
||||
}
|
||||
|
@ -55,9 +55,9 @@ class Rule extends Model
|
||||
*/
|
||||
public static function routeBinder(string $value): Rule
|
||||
{
|
||||
if ($guard->check()) {
|
||||
if (auth()->check()) {
|
||||
$ruleId = intval($value);
|
||||
$rule = $guard->user()->rules()->find($ruleId);
|
||||
$rule = auth()->user()->rules()->find($ruleId);
|
||||
if (!is_null($rule)) {
|
||||
return $rule;
|
||||
}
|
||||
|
@ -58,9 +58,9 @@ class RuleGroup extends Model
|
||||
*/
|
||||
public static function routeBinder(string $value): RuleGroup
|
||||
{
|
||||
if ($guard->check()) {
|
||||
if (auth()->check()) {
|
||||
$ruleGroupId = intval($value);
|
||||
$ruleGroup = $guard->user()->ruleGroups()->find($ruleGroupId);
|
||||
$ruleGroup = auth()->user()->ruleGroups()->find($ruleGroupId);
|
||||
if (!is_null($ruleGroup)) {
|
||||
return $ruleGroup;
|
||||
}
|
||||
|
@ -93,9 +93,9 @@ class Tag extends Model
|
||||
*/
|
||||
public static function routeBinder(string $value): Tag
|
||||
{
|
||||
if ($guard->check()) {
|
||||
if (auth()->check()) {
|
||||
$tagId = intval($value);
|
||||
$tag = $guard->user()->tags()->find($tagId);
|
||||
$tag = auth()->user()->tags()->find($tagId);
|
||||
if (!is_null($tag)) {
|
||||
return $tag;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ class TransactionCurrency extends Model
|
||||
*/
|
||||
public static function routeBinder(string $value): TransactionCurrency
|
||||
{
|
||||
if ($guard->check()) {
|
||||
if (auth()->check()) {
|
||||
$currencyId = intval($value);
|
||||
$currency = self::find($currencyId);
|
||||
if (!is_null($currency)) {
|
||||
|
@ -88,9 +88,9 @@ class TransactionJournal extends Model
|
||||
*/
|
||||
public static function routeBinder(string $value): TransactionJournal
|
||||
{
|
||||
if ($guard->check()) {
|
||||
if (auth()->check()) {
|
||||
$journalId = intval($value);
|
||||
$journal = $guard->user()->transactionJournals()->where('transaction_journals.id', $journalId)
|
||||
$journal = auth()->user()->transactionJournals()->where('transaction_journals.id', $journalId)
|
||||
->first(['transaction_journals.*']);
|
||||
if (!is_null($journal)) {
|
||||
return $journal;
|
||||
|
@ -46,13 +46,13 @@ class TransactionJournalLink extends Model
|
||||
*/
|
||||
public static function routeBinder(string $value): TransactionJournalLink
|
||||
{
|
||||
if ($guard->check()) {
|
||||
if (auth()->check()) {
|
||||
$linkId = intval($value);
|
||||
$link = self::where('journal_links.id', $linkId)
|
||||
->leftJoin('transaction_journals as t_a', 't_a.id', '=', 'source_id')
|
||||
->leftJoin('transaction_journals as t_b', 't_b.id', '=', 'destination_id')
|
||||
->where('t_a.user_id', $guard->user()->id)
|
||||
->where('t_b.user_id', $guard->user()->id)
|
||||
->where('t_a.user_id', auth()->user()->id)
|
||||
->where('t_b.user_id', auth()->user()->id)
|
||||
->first(['journal_links.*']);
|
||||
if (!is_null($link)) {
|
||||
return $link;
|
||||
|
@ -74,7 +74,7 @@ class TransactionType extends Model
|
||||
*/
|
||||
public static function routeBinder(string $type): TransactionType
|
||||
{
|
||||
if (!$guard->check()) {
|
||||
if (!auth()->check()) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
$transactionType = self::where('type', ucfirst($type))->first();
|
||||
|
Loading…
Reference in New Issue
Block a user