<?php

namespace {{ namespace }};

use {{ namespacedModel }};
use {{ rootNamespace }}Http\Controllers\Controller;
{{ requestUses }}

class {{ class }} extends Controller
{
    /**
     * Display a listing of the resource.
     */
    public function index()
    {
				$data = [];
				
				$data['items'] = {{ model }}::all();

        return view('{{ tableName }}.index', $data);
    }

    /**
     * Show the form for creating a new resource.
     */
    public function create()
    {
				$data = []; 

        return view('{{ tableName }}.create_edit', $data);
    }

    /**
     * Store a newly created resource in storage.
     */
    public function store({{ storeRequest }} $request)
    {
				$validated = $request->validated();

        //
				${{ modelVariable }} = new {{ model }}();

				//insert the values into the model
				// {{ valuesForCreation }}

				${{ modelVariable }}->save();

        return redirect()->route('{{ tableName }}.index');
    }

    /**
     * Display the specified resource.
     */
    public function show({{ model }} ${{ modelVariable }})
    {
				$data = [];
				
				$data['item'] = ${{ modelVariable }};

				return view('{{ tableName }}.show', $data); 
    }

    /**
     * Show the form for editing the specified resource.
     */
    public function edit({{ model }} ${{ modelVariable }})
    {
			$data = [];

			$data['item'] = ${{ modelVariable }};

			return view('{{ tableName }}.create_edit', $data);
    }

    /**
     * Update the specified resource in storage.
     */
    public function update({{ updateRequest }} $request, {{ model }} ${{ modelVariable }})
    {
				$validated = $request->validated();

        // Set the variables
				//{{ valuesForCreation }}

				${{ modelVariable }}->save();

				return redirect()->route('{{ tableName }}.index');
    }

    /**
     * Remove the specified resource from storage.
     */
    public function destroy({{ model }} ${{ modelVariable }})
    {
        //
				${{ modelVariable }}->delete();

				return redirect()->route('{{ tableName }}.index');
    }
}
