Added my snippets and current settings on Linux
This commit is contained in:
74
Packages/User/laravel_controller.sublime-snippet
Normal file
74
Packages/User/laravel_controller.sublime-snippet
Normal file
@ -0,0 +1,74 @@
|
||||
<snippet>
|
||||
<content><![CDATA[
|
||||
public function index()
|
||||
{
|
||||
\$data = [
|
||||
'${2:models}' => ${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.");
|
||||
}
|
||||
]]></content>
|
||||
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
|
||||
<tabTrigger>laracontroller</tabTrigger>
|
||||
<!-- Optional: Set a scope to limit where the snippet will trigger -->
|
||||
<!-- <scope>source.python</scope> -->
|
||||
</snippet>
|
Reference in New Issue
Block a user