view('$COLLECTION$.index')->render() ->with('items', $MODEL$::all()); } /** * Show the form for creating a new resource. * GET /$COLLECTION$/create * * @return Response */ public function create() { return $this->view('$COLLECTION$.edit')->render() ->with([]); } /** * Store a newly created resource in storage. * POST /$COLLECTION$ * * @return Response */ public function store() { $inputs = Input::all(); $validator = Validator::make($inputs, $MODEL$::$rules, $MODEL$::$messages); // validation if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $inputs['created_by'] = Auth::user()->id; $row = $MODEL$::create($inputs); if ($row) { LogSystem::createRow('Create $MODEL$', $row->title, $row); Notification::success('Successfully', 'The Item has been created', 'thumbs-up bounce animated'); } else { Notification::error('Oops', 'Something went wrong', 'warning shake animated'); } return Redirect::route('admin.$COLLECTION$.index'); } /** * Display the specified resource. * GET /$COLLECTION$/{id} * * @param int $id * @return Response */ public function show($id) { $item = $MODEL$::findOrFail($id); return $this->view('$COLLECTION$.show')->render() ->with('item', $item); } /** * Show the form for editing the specified resource. * GET /$COLLECTION$/{id}/edit * * @param int $id * @return Response */ public function edit($id) { $item = $MODEL$::findOrFail($id); return $this->view('$COLLECTION$.edit')->render() ->with('item', $item); } /** * Update the specified resource in storage. * PUT /$COLLECTION$/{id} * * @param int $id * @return Response */ public function update($id) { $row = $MODEL$::findOrFail($id); $inputs = Input::all(); $validator = Validator::make($inputs, $MODEL$::$rules, $MODEL$::$messages); // validation if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $inputs['updated_by'] = Auth::user()->id; $row->update($inputs); $row->touch(); LogSystem::createRow('Update $MODEL$', $row->title, $row); Notification::success('Successfully', 'The Item has been updated', 'thumbs-up bounce animated'); return Redirect::route('admin.$COLLECTION$.index'); } /** * Remove the specified resource from storage. * DELETE /$COLLECTION$/{id} * * @param int $id * @return Response */ public function destroy($id) { if (Input::get('_id') == $id) { $row = $MODEL$::findOrFail($id); $row->update(['deleted_by' => Auth::user()->id]); if ($row->delete() >= 1) { LogSystem::createRow('Delete $MODEL$', $row->title, $row); Notification::success('Successfully', 'The Item has been removed', 'thumbs-up bounce animated'); } else { Notification::error('Oops', 'We could not find the item to delete', 'warning shake animated'); } } else { Notification::error('Oops', 'The Item id does not match', 'warning shake animated'); } return Redirect::route('admin.$COLLECTION$.index'); } }