${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()) {
return redirect()->route('dashboard.${2:models}.index')->with('status', "Successfully added {\$${3:model}->${4:field}} as a ${3:model}.");
}
return redirect()->back()->with('error', 'Unable to save that ${3:model}. Check the error logs.');
}
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()) {
return redirect()->route('dashboard.${2:models}.index')->with('status', "Successfully updated {\$${3:model}->${4:field}}.");
}
return redirect()->back()->with('error', "Unable to update {\$${3:model}->${4:field}}. Check the error logs.");
}
public function destroy(${1:MODEL} \$${3:model})
{
\$${4:field} = \$${3:model}->${4:field};
if (\$${3:model}->delete()) {
return redirect()->route('dashboard.${2:models}.index')->with('status', "Successfully removed {\$${4:field}}.");
}
return redirect()->back()->with('error', "Unable to remove {\$${4:field}}. Check the error logs.");
}
]]>
laracontroller