${1:Model}::where('user_id', \$request->user()->id)->paginate(),
];
return Inertia::render('Dashboard/${2:Models}/Index')->with(\$data);
}
public function show(${1:Model} \$${4:model})
{
\$data = [
'${4:model}' => \$${4:model},
];
return Inertia::render('Dashboard/${2:Models}/Show')->with(\$data);
}
public function create()
{
\$data = [];
return Inertia::render('Dashboard/${2:Models}/Create')->with(\$data);
}
public function store(Request \$request)
{
\$${4:model} = new ${1:Model}();
// assign model fields
if (\$${4:model}->save()) {
\$request->session()->flash('flash', ['bannerStyle' => 'success', 'banner' => "Successfully added {\$${4:model}->${5:field}}."]);
return redirect()->route('dashboard.${3:models}.index')->with('status', "Successfully added {\$${4:model}->${5:field}}.");
}
\$request->session()->flash('flash', ['bannerStyle' => 'danger', 'banner' => "Unable to save that ${4:model}."]);
return redirect()->back()->with('error', 'Unable to save that ${4:model}.');
}
public function edit(Request \$request, ${1:Model} \$${4:model})
{
\$data = [
'${4:model}' => \$${4:model},
];
return Inertia::render('Dashboard/${2:Models}/Edit')->with(\$data);
}
public function update(Request \$request, ${1:Model} \$${4:model})
{
// assign model fields
if (\$${4:model}->update()) {
\$request->session()->flash('flash', ['bannerStyle' => 'success', 'banner' => "Successfully updated {\$${4:model}->${5:field}}."]);
return redirect()->route('dashboard.${3:models}.index')->with('status', "Successfully updated {\$${4:model}->${5:field}}.");
}
\$request->session()->flash('flash', ['bannerStyle' => 'danger', 'banner' => "Unable to update {\$${4:model}->${5:field}}."]);
return redirect()->back()->with('error', "Unable to update {\$${4:model}->${5:field}}.");
}
public function destroy(Request \$request, ${1:Model} \$${4:model})
{
\$${5:field} = \$${4:model}->${5:field};
if (\$${4:model}->delete()) {
\$request->session()->flash('flash', ['bannerStyle' => 'success', 'banner' => "Successfully removed {\$${5:field}}."]);
return redirect()->route('dashboard.${3:models}.index')->with('status', "Successfully removed {\$${5:field}}.");
}
\$request->session()->flash('flash', ['bannerStyle' => 'danger', 'banner' => "Unable to remove {\$${5:field}}."]);
return redirect()->back()->with('error', "Unable to remove {\$${5:field}}.");
}
]]>
laracontroller