Создаем роутер и модель для CRUD

 Исходя из основ MCV для правильной работы нашего приложения нужен контроллер и модель, воспользуемся консолью и создадим их

Php artisan make:controller ProjectController --resource --model=Project

 Так как мы создаем стандартный CRUD, для него необходимо добавить методы реализации чтения, записи, обновления и удаления в контроллере. Также покажем индексную страницу.

  1. index()
  2. create()
  3. store(Request, $request)
  4. show(Project, $project)
  5. edit(Project, $project)
  6. update(Request, $request, Project, $project)
  7. destroy( Project, $project)
<?php
namespace App\Http\Controllers;

use App\Models\test;
use App\Models\testType;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class testController extends Controller
{
    /**
     * Display a listing of the test.
     *
     * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Http\Response|\Illuminate\View\View
     */
    public function index()
    {
        $testType = testType::all('name', 'id')->keyBy('id')->toArray();
        $test = test::latest()->paginate(5);

        return view('test.index', compact('test', 'testType'))
            ->with('i', (request()->input('page', 1) - 1) * 5);
    }

    /**
     * Show the form for creating a new test.
     *
     * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Http\Response|\Illuminate\View\View
     */
    public function create()
    {
        $testType = testType::all('name', 'id');

        return view('test.create', compact('testType'));
    }


    /**
     * Store a newly created test in storage.
     *
     * @param \Illuminate\Http\Request $request
     * @return \Illuminate\Http\RedirectResponse
     */
    public function store(Request $request)
    {
        $request->validate([
            'type' => 'required',
            'amount' => 'required',
            'created_at' => 'required'
        ]);

        test::create([
            'type' => $request['type'],
            'amount' => $request['amount'],
            'created_at' => $request['create_at'],
            'user_id' => Auth::id()
        ]);

        return redirect()->route('test.index')
            ->with('success', 'test created successfully.');
    }

    /**
     * Display the specified resource.
     *
     * @param \App\Models\test $test
     * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Http\Response|\Illuminate\View\View
     */
    public function show(test $test)
    {
        $testType = testType::all('name', 'id')->keyBy('id')->toArray();

        return view('test.show', compact('test', 'testType'));
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param \App\Models\test $test
     * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Http\Response|\Illuminate\View\View
     */
    public function edit(test $test)
    {
        $testType = testType::all('name', 'id');

        return view('test.edit', compact('test', 'testType'));
    }

    /**
     * Update the specified resource in storage.
     *
     * @param \Illuminate\Http\Request $request
     * @param \App\Models\test $test
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response
     */
    public function update(Request $request, test $test)
    {
        $request->validate([
            'amount' => 'required',
            'type' => 'required',
            'create_at' => 'required',
        ]);
        $test->update($request->all());

        return redirect()->route('test.index')
            ->with('success', 'test updated successfully');
    }


    /**
     * Remove the specified resource from storage.
     * @param \App\Models\test $test
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response
     * @throws \Exception
     */
    public function destroy(test $test)
    {
        $test->delete();

        return redirect()->route('test.index')
            ->with('success', 'test deleted successfully');
    }
}

Не забываем отредактировать модель, в ней укажем существующие поля из базы, покажем название таблицы, подключим трей "HasFactory"

<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Income extends Model
{
    use HasFactory;

    /**
     * The name of the table in the database
     * @var string
     */
    protected $table = 'test';

    public $timestamps = true;

    protected $fillable = [
        'id',
        'name',
        'created_at',
        'updated_at'
    ];
}