Skip to content

Instantly share code, notes, and snippets.

@thecodeholic
Created February 26, 2024 19:29
Show Gist options
  • Save thecodeholic/806a41fda32cfb1c7790669862cf5c80 to your computer and use it in GitHub Desktop.
Save thecodeholic/806a41fda32cfb1c7790669862cf5c80 to your computer and use it in GitHub Desktop.
PHP/Laravel Live snippets for VSCode
{
"Create public function": {
"prefix": "pubf",
"body": [
"public function $1()",
"{",
"\t$2",
"}",
],
"description": "Create public function"
},
"Create private function": {
"prefix": "prif",
"body": [
"private function $1()",
"{",
"\t$2",
"}",
],
"description": "Create private function"
},
"Create protected function": {
"prefix": "prof",
"body": [
"protected function $1()",
"{",
"\t$2",
"}",
],
"description": "Create protected function"
},
"Create public static function": {
"prefix": "pubsf",
"body": [
"public static function $1()",
"{",
"\t$2",
"}",
],
"description": "Create public static function"
},
"Create private static function": {
"prefix": "prif",
"body": [
"private static function $1()",
"{",
"\t$2",
"}",
],
"description": "Create private static function"
},
"Create protected static function": {
"prefix": "prof",
"body": [
"protected static function $1()",
"{",
"\t$2",
"}",
],
"description": "Create protected static function"
},
"Create public function with belongsTo": {
"prefix": "belongs",
"body": [
"public function $1()",
"{",
"\treturn \\$this->belongsTo($2::class);",
"}",
],
"description": "Create public function with belongsTo"
},
"Create public function with has many": {
"prefix": "hasm",
"body": [
"public function $1()",
"{",
"\treturn \\$this->hasMany($2::class);",
"}",
],
"description": "Create public function with has many"
}
}
@pratiktank2002
Copy link

this is for creating $fillable array in Laravel modal

	"Create protected $fillable": {
		"prefix": "fillable",
		"body": [
			"protected \\$fillable = [",
			"\t'$1', '$2', '$3', '$4',",
			"];"
		],
		"description": "Create protected $fillable array"
	}

@reelsergealain
Copy link

"Create protected $guarded": {
"prefix": "guarded",
"body": [
"protected \$guarded= [""];"
],
"description": "Create protected $guarded array"
}

@jaminhood
Copy link

Caught some bugs in the snippets above..
line 43: prisf instead of prif (prif is already in use for private functions)..
line 53: prosf instead of prof (prof is already in use for protected functions)..

Hopefully this was helpful..

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