Skip to content

Instantly share code, notes, and snippets.

@robbinbenard
Last active March 16, 2020 00:38
Show Gist options
  • Select an option

  • Save robbinbenard/b46951759f6d33a4432abcca2b2ecf0f to your computer and use it in GitHub Desktop.

Select an option

Save robbinbenard/b46951759f6d33a4432abcca2b2ecf0f to your computer and use it in GitHub Desktop.
{
/*
// Place your snippets for PHP here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, ${id} and ${id:label} and ${1:label} for variables. Variables with the same id are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');",
"$2"
],
"description": "Log output to console"
}
*/
"test": {
"prefix": "test",
"description": "create a test method",
"body": [
"/** @test */",
"public function ${1:example_test}()",
"{",
"\t$2",
"}",
],
},
"hasMany": {
"prefix": "hasMany",
"description": "Laravel: create a HasMany relation",
"body": [
"/**",
" * Get the related $1",
" *",
" * @return \\Illuminate\\Database\\Eloquent\\Relations\\HasMany",
" */",
"public function $1()",
"{",
" return \\$this->hasMany(\\App\\\\$2::class);",
"}",
],
},
"hasOne": {
"prefix": "hasOne",
"description": "Laravel: create a HasOne relation",
"body": [
"/**",
" * Get the related $1",
" *",
" * @return \\Illuminate\\Database\\Eloquent\\Relations\\HasOne",
" */",
"public function $1()",
"{",
" return \\$this->hasOne(\\App\\\\$2::class);",
"}",
],
},
"belongsTo": {
"prefix": "belongsTo",
"description": "Laravel: create a belongsTo relation",
"body": [
"/**",
" * Get the related $1",
" *",
" * @return \\Illuminate\\Database\\Eloquent\\Relations\\BelongsTo",
" */",
"public function $1()",
"{",
" return \\$this->belongsTo(\\App\\\\$2::class);",
"}",
],
},
"foreignKey": {
"prefix": "foreignKey",
"body": [
"$$table->foreign('$1')->references('${3:id}')->on('$2')->onDelete('${4:cascade}')->onUpdate('${5:cascade}');"
]
},
"fillable": {
"prefix": "fillable",
"description": "Laravel: create fillable property",
"body": [
"/**",
" * The attributes that are mass assignable.",
" *",
" * @var array",
" */",
"protected \\$fillable = [",
" '${1:name}',",
"];",
],
},
"guarded": {
"prefix": "guarded",
"description": "Laravel: create guarded property",
"body": [
"/**",
" * The attributes that aren't mass assignable.",
" *",
" * @var array",
" */",
"protected \\$guarded = [];",
],
},
"index": {
"prefix": "index",
"description": "Laravel: index method",
"body": [
"/**",
" * Display a listing of the resource.",
" *",
" * @return \\\\Illuminate\\\\Http\\\\Response",
" */",
"public function index()",
"{",
" ${1://}",
"}",
],
},
"create": {
"prefix": "create",
"description": "Laravel: create method",
"body": [
"/**",
" * Show the form for creating a new resource.",
" *",
" * @return \\\\Illuminate\\\\Http\\\\Response",
" */",
"public function create()",
"{",
" ${1://}",
"}",
],
},
"store": {
"prefix": "store",
"description": "Laravel: store method",
"body": [
"/**",
" * Display a listing of the resource.",
" *",
" * @param \\\\Illuminate\\\\Http\\\\Request $request",
" * @return \\\\Illuminate\\\\Http\\\\Response",
" */",
"public function store(Request \\$request)",
"{",
" ${1://}",
"}",
],
},
"show": {
"prefix": "show",
"description": "Laravel: show method",
"body": [
"/**",
" * Display the specified resource.",
" *",
" * @param \\\\App\\\\${1:Model} \\$${2:model}",
" * @return \\\\Illuminate\\\\Http\\\\Response",
" */",
"public function show(${1:Model} \\$${2:model})",
"{",
" ${3://}",
"}",
],
},
"edit": {
"prefix": "edit",
"description": "Laravel: edit method",
"body": [
"/**",
" * Show the form for editing the specified resource.",
" *",
" * @param \\\\App\\\\${1:Model} \\$${2:model}",
" * @return \\\\Illuminate\\\\Http\\\\Response",
" */",
"public function edit(${1:Model} \\$${2:model})",
"{",
" ${3://}",
"}",
],
},
"update": {
"prefix": "update",
"description": "Laravel: update method",
"body": [
"/**",
" * Update the specified resource in storage.",
" *",
" * @param \\\\Illuminate\\\\Http\\\\Request $request",
" * @param \\\\App\\\\${1:Model} \\$${2:model}",
" * @return \\\\Illuminate\\\\Http\\\\Response",
" */",
"public function update(Request \\$request, ${1:Model} \\$${2:model})",
"{",
" ${3://}",
"}",
],
},
"destroy": {
"prefix": "destroy",
"description": "Laravel: destroy method",
"body": [
"/**",
" * Remove the specified resource from storage.",
" *",
" * @param \\\\App\\\\${1:Model} \\$${2:model}",
" * @return \\\\Illuminate\\\\Http\\\\Response",
" */",
"public function destroy(${1:Model} \\$${2:model})",
"{",
" ${3://}",
"}",
],
},
}
@ao-jhelmich
Copy link

ao-jhelmich commented Nov 6, 2019

"foreignKey": {
		"prefix": "foreignKey",
		"body": [
			"$$table->foreign('$1')->references('${3:id}')->on('$2')->onDelete('${4:cascade}')->onUpdate('${5:cascade}');"
		]
	},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment