2016-12-08 22:39:15 +02:00

123 lines
3.0 KiB
Plaintext
Executable File

<?php
namespace $CLASS_NAMESPACE$;
use Auth;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
use App\Http\Controllers\BaseController;
use App\Services\DatatableService;
use Modules\$STUDLY_NAME$\Repositories\$STUDLY_NAME$Repository;
use Modules\$STUDLY_NAME$\Datatables\$STUDLY_NAME$Datatable;
class $CLASS$ extends BaseController
{
protected $$STUDLY_NAME$Repo;
//protected $entityType = '$LOWER_NAME$';
public function __construct($STUDLY_NAME$Repository $$LOWER_NAME$Repo)
{
//parent::__construct();
$this->$LOWER_NAME$Repo = $$LOWER_NAME$Repo;
}
/**
* Display a listing of the resource.
* @return Response
*/
public function index()
{
return view('list_wrapper', [
'entityType' => '$LOWER_NAME$',
'datatable' => new $STUDLY_NAME$Datatable(),
'title' => trans('texts.$LOWER_NAME$'),
]);
}
public function datatable(DatatableService $datatableService)
{
$search = request()->input('test');
$userId = Auth::user()->filterId();
$datatable = new $STUDLY_NAME$Datatable();
$query = $this->$LOWER_NAME$Repo->find($search, $userId);
return $datatableService->createDatatable($datatable, $query);
}
/**
* Show the form for creating a new resource.
* @return Response
*/
public function create()
{
$data = [
'$LOWER_NAME$' => null,
'method' => 'POST',
'url' => '$LOWER_NAME$',
'title' => trans('texts.new_$LOWER_NAME$'),
];
return view('$LOWER_NAME$::edit', $data);
}
/**
* Store a newly created resource in storage.
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$$LOWER_NAME$ = $this->$LOWER_NAME$Repo->save($request->input());
return redirect()->to($$LOWER_NAME$->present()->editUrl)
->with('message', trans('texts.created_$LOWER_NAME$'));
}
/**
* Show the form for editing the specified resource.
* @return Response
*/
public function edit($STUDLY_NAME$Request $request)
{
$$LOWER_NAME$ = $request->entity();
$data = [
'$LOWER_NAME$' => $$LOWER_NAME$,
'method' => 'PUT',
'url' => '$LOWER_NAME$/' . $$LOWER_NAME$->public_id,
'title' => trans('texts.edit_$LOWER_NAME$'),
];
return view('$LOWER_NAME$::edit', $data);
}
/**
* Show the form for editing a resource.
* @return Response
*/
public function show(Request $request)
{
return redirect()->to("$LOWER_NAME$/{$request->$LOWER_NAME$}/edit");
}
/**
* Update the specified resource in storage.
* @param Request $request
* @return Response
*/
public function update(Request $request)
{
}
/**
* Remove the specified resource from storage.
* @return Response
*/
public function destroy()
{
}
}