Exemplo n.º 1
0
 /**
  * @covers FireflyIII\Repositories\Journal\JournalRepository::delete
  * @covers FireflyIII\Providers\EventServiceProvider::boot
  * @covers FireflyIII\Providers\EventServiceProvider::registerDeleteEvents
  */
 public function testDelete()
 {
     $journal = FactoryMuffin::create('FireflyIII\\Models\\TransactionJournal');
     $transaction = $journal->transactions[0];
     $this->object->delete($journal);
     $this->assertEquals(0, TransactionJournal::where('id', $journal->id)->whereNull('deleted_at')->count());
     $this->assertEquals(0, Transaction::where('id', $transaction->id)->whereNull('deleted_at')->count());
 }
 /**
  * @param $value
  * @param $route
  *
  * @return mixed
  */
 public static function routeBinder($value, $route) : TransactionJournal
 {
     if (auth()->check()) {
         $object = TransactionJournal::where('transaction_journals.id', $value)->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')->where('completed', 0)->where('user_id', auth()->user()->id)->first(['transaction_journals.*']);
         if ($object) {
             return $object;
         }
     }
     throw new NotFoundHttpException();
 }
Exemplo n.º 3
0
 /**
  * @param $value
  *
  * @return mixed
  * @throws NotFoundHttpException
  */
 public static function routeBinder($value)
 {
     if (Auth::check()) {
         $validTypes = [TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER];
         $object = TransactionJournal::where('transaction_journals.id', $value)->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')->whereIn('transaction_types.type', $validTypes)->where('user_id', Auth::user()->id)->first(['transaction_journals.*']);
         if ($object) {
             return $object;
         }
     }
     throw new NotFoundHttpException();
 }
Exemplo n.º 4
0
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionJournal;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
// models
Route::bind('account', function ($value) {
    if (Auth::check()) {
        $object = Account::leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')->where('account_types.editable', 1)->where('accounts.id', $value)->where('user_id', Auth::user()->id)->first(['accounts.*']);
        if ($object) {
            return $object;
        }
    }
    throw new NotFoundHttpException();
});
Route::bind('tj', function ($value) {
    if (Auth::check()) {
        $object = TransactionJournal::where('id', $value)->where('user_id', Auth::user()->id)->first();
        if ($object) {
            return $object;
        }
    }
    throw new NotFoundHttpException();
});
Route::bind('attachment', function ($value) {
    if (Auth::check()) {
        $object = Attachment::where('id', $value)->where('user_id', Auth::user()->id)->first();
        if ($object) {
            return $object;
        }
    }
    throw new NotFoundHttpException();
});