Fix bug in store functions of both EarningsController and SpendingsController
MODIFY
app/Http/Controllers/EarningsController.php
app/Http/Controllers/EarningsController.php
@@ -26,16 +26,12 @@ class EarningsController extends Controller {
}
public function store(Request $request) {
- $date = $request->input('date');
- $description = $request->input('description');
- $amount = $request->input('amount');
-
$earning = new Earning;
$earning->user_id = Auth::user()->id;
- $earning->date = $date;
- $earning->description = $description;
- $earning->amount = $amount;
+ $earning->happened_on = $request->input('date');
+ $earning->description = $request->input('description');
+ $earning->amount = $request->input('amount');
$earning->save();

MODIFY
app/Http/Controllers/SpendingsController.php
app/Http/Controllers/SpendingsController.php
@@ -29,18 +29,13 @@ class SpendingsController extends Controller {
}
public function store(Request $request) {
- $tag_id = $request->input('tag_id');
- $date = $request->input('date');
- $description = $request->input('description');
- $amount = $request->input('amount');
-
$spending = new Spending;
$spending->user_id = Auth::user()->id;
- $spending->tag_id = $tag_id;
- $spending->date = $date;
- $spending->description = $description;
- $spending->amount = $amount;
+ $spending->tag_id = $request->input('tag_id');
+ $spending->happened_on = $request->input('date');
+ $spending->description = $request->input('description');
+ $spending->amount = $request->input('amount');
$spending->save();

Fix bug in store functions of both EarningsController and SpendingsController