Esempio n. 1
0
 /**
  * Run the database seed for account "Vacances en Écosse".
  *
  * @return void
  */
 public function runAccount5()
 {
     Envelope::create(['account_id' => 5, 'name' => 'Logement', 'icon' => 'fa-home']);
     Envelope::create(['account_id' => 5, 'name' => 'Transports', 'icon' => 'fa-car']);
     Envelope::create(['account_id' => 5, 'name' => 'Quotidien', 'icon' => 'fa-cutlery']);
     Envelope::create(['account_id' => 5, 'name' => 'Sorties', 'icon' => 'fa-book']);
 }
Esempio n. 2
0
 /**
  * Query envelopes related to accounts related to user (even if not owned by the user)
  * @return \Illuminate\Database\Eloquent\Builder Query
  */
 public function envelopes()
 {
     return Envelope::whereIn('account_id', function (QueryBuilder $query) {
         $query->select('account_id')->from('account_user')->where('user_id', $this->id);
     })->withTrashed()->orderBy('name');
 }
Esempio n. 3
0
 /**
  * Restore archived envelope
  * @param  string $envelopeId Envelope primary key
  * @return \Illuminate\Http\RedirectResponse
  */
 public function getRestore($envelopeId)
 {
     $envelope = Envelope::onlyTrashed()->find($envelopeId);
     if (is_null($envelope) || is_null(Auth::user()->accounts()->find($envelope->account_id))) {
         return redirect()->action('HomeController@getIndex')->withErrors(trans('envelope.view.notfoundMessage'));
     }
     $envelope->restore();
     return redirect()->action('EnvelopeController@getView', $envelope)->withSuccess(trans('envelope.restore.successMessage', ['envelope' => $envelope]));
 }
Esempio n. 4
0
 /**
  * Prepare view for authenticated user with several accounts
  * @param  Collection $accounts Account collection
  * @return Illuminate\View\View|\Illuminate\Contracts\View\Factory View
  */
 private function builIndex(Collection $accounts)
 {
     $data = ['accounts' => $accounts, 'accountsBalance' => $this->getAccountsBalance($accounts), 'accountsChart' => DonutChart::forge($accounts, Carbon::today()), 'envelopesBalance' => $this->getEnvelopesBalance($accounts), 'envelopesChart' => DonutChart::forge(Envelope::whereIn('account_id', $accounts->pluck('id'))->get(), Carbon::today())];
     return view('home.authenticated', $data);
 }