Create EarningsController with create and store functions
MODIFY
app/Earning.php
app/Earning.php
@@ -5,5 +5,5 @@ namespace App;
use Illuminate\Database\Eloquent\Model;
class Earning extends Model {
- //
+ public $timestamps = false;
}

ADD
app/Http/Controllers/EarningsController.php
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+
+use App\Earning;
+
+use Auth;
+
+class EarningsController extends Controller {
+ public function create() {
+ return view('earnings.create');
+ }
+
+ 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->save();
+
+ return redirect()->route('dashboard_get');
+ }
+}

ADD
resources/views/earnings/create.blade.php
+@extends('layout')
+
+@section('body')
+ <h1>Create earning</h1>
+ <div class="box">
+ <div class="box__section">
+ <form method="POST" action="/earnings">
+ {{ csrf_field() }}
+ <label>Date</label>
+ <input type="text" name="date" />
+ <label>Description</label>
+ <input type="text" name="description" />
+ <label>Amount</label>
+ <input type="text" name="amount" />
+ <input type="submit" value="Create earning" />
+ </form>
+ </div>
+ </div>
+@endsection

MODIFY
routes/web.php
routes/web.php
@@ -6,6 +6,9 @@ Route::post('/login', 'LoginController@store')->name('login_post');
Route::group(['middleware' => ['auth']], function () {
Route::get('/dashboard', 'DashboardController@index')->name('dashboard_get');
+ Route::get('/earnings/create', 'EarningsController@create')->name('earnings_create_get');
+ Route::post('/earnings', 'EarningsController@store')->name('earnings_store_post');
+
Route::get('/reports', 'ReportsController@index')->name('reports_index_get');
Route::get('/reports/{year}/{month}', 'ReportsController@show')->name('reports_show_get');

Create EarningsController with create and store functions