${1:MODEL}::where('user_id', Auth::id())->paginate(),
];
return view('${2:models}.index')->with(\$data);
}
public function show(${1:MODEL} \$${3:model})
{
\$data = [
'${3:model}' => \$${3:model},
];
return view('${2:models}.show')->with(\$data);
}
public function create()
{
\$data = [];
return view('${2:models}.create')->with(\$data);
}
public function store(Request \$request)
{
\$${3:model} = new ${1:MODEL}();
// assign model fields
if (\$${3:model}->save()) {
\$request->session()->flash('status', "Successfully added {\$${3:model}->${4:field}}.");
return redirect()->route('dashboard.${2:models}.index')->with('status', "Successfully added {\$${3:model}->${4:field}}.");
}
\$request->session()->flash('error', 'Unable to save that ${3:model}.');
return redirect()->back()->with('error', 'Unable to save that ${3:model}.');
}
public function edit(${1:MODEL} \$${3:model})
{
\$data = [
'${3:model}' => \$${3:model},
];
return view('${2:models}.edit')->with(\$data);
}
public function update(Request \$request, ${1:MODEL} \$${3:model})
{
// assign model fields
if (\$${3:model}->update()) {
\$request->session()->flash('status', "Successfully updated {\$${3:model}->${4:field}}.");
return redirect()->route('dashboard.${2:models}.index')->with('status', "Successfully updated {\$${3:model}->${4:field}}.");
}
\$request->session()->flash('error', "Unable to update {\$${3:model}->${4:field}}.");
return redirect()->back()->with('error', "Unable to update {\$${3:model}->${4:field}}.");
}
public function destroy(Request \$request, ${1:MODEL} \$${3:model})
{
\$${4:field} = \$${3:model}->${4:field};
if (\$${3:model}->delete()) {
\$request->session()->flash('status', "Successfully removed {\$${4:field}}.");
return redirect()->route('dashboard.${2:models}.index')->with('status', "Successfully removed {\$${4:field}}.");
}
\$request->session()->flash('error', "Unable to remove {\$${4:field}}.");
return redirect()->back()->with('error', "Unable to remove {\$${4:field}}.");
}
]]>
laracontroller