<?php

namespace App\Http\Controllers;

use App\Http\Requests\{{modelName}}Request;
use App\Services\{{modelName}}Service;

class {{modelName}}Controller extends Controller
{

    private ${{modelNameSingularLowerCase}}Service;

	public function __construct({{modelName}}Service ${{modelNameSingularLowerCase}}Service)
	{
		$this->{{modelNameSingularLowerCase}}Service = ${{modelNameSingularLowerCase}}Service;
	}

    public function index()
    {
        ${{modelNamePluralLowerCase}} = $this->{{modelNameSingularLowerCase}}Service->getAll();

        return response()->json(${{modelNamePluralLowerCase}}, 201);
    }

    public function store({{modelName}}Request $request)
    {
        ${{modelNameSingularLowerCase}} = $this->{{modelNameSingularLowerCase}}Service->save($request->all());

        return response()->json(${{modelNameSingularLowerCase}}, 201);
    }

    public function show($id)
    {
        ${{modelNameSingularLowerCase}} = $this->{{modelNameSingularLowerCase}}Service->get($id);

        return response()->json(${{modelNameSingularLowerCase}});
    }

    public function destroy($id)
    {
      	$this->{{modelNameSingularLowerCase}}Service->delete($id);
        return response()->json(null, 204);
    }
}