public function postEvent(Request $request) { $event = $request->all(); $event['weight'] = 0; $finance = FinancialStatus::all(); foreach ($finance as $fin) { $fin->delete(); } Event::create($event); return redirect('/admin'); }
public function postFinancialStatus(Request $request) { $data = $request->all(); $latest = FinancialStatus::latest('created_at')->first(); $event_id = Event::latest('id')->first()->id; $head_id = Head::where('event_id', $event_id)->where('position', 'Finance Committee Head')->first()->id; $data['weekly_income'] = $data['cash_in'] - $data['cash_out']; $data['cash_in_hand'] = $latest->cash_in_hand + $data['weekly_income']; $data['target_budget'] = $latest['target_budget']; $data['event_id'] = $event_id; $data['head_id'] = $head_id; FinancialStatus::create($data); return redirect("/"); }
public function run() { FinancialStatus::create(['id' => '1', 'cash_in' => '2000', 'cash_out' => '1500', 'weekly_income' => '500', 'payables' => '4900', 'cash_in_hand' => '7543.50', 'target_budget' => '23543.50', 'event_id' => '2', 'head_id' => Head::where('event_id', 2)->where('position', 'Finance Committee Head')->first()->id]); $this->call('EventShoutsSeeder'); }