Created
February 26, 2024 19:29
-
-
Save thecodeholic/806a41fda32cfb1c7790669862cf5c80 to your computer and use it in GitHub Desktop.
PHP/Laravel Live snippets for VSCode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} | |
} |
"Create protected $guarded": {
"prefix": "guarded",
"body": [
"protected \$guarded= [""];"
],
"description": "Create protected $guarded array"
}
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..
" Route structure ": {
"prefix": "rt",
"body": [
"Route::${1|get,post,put,patch,delete,head,options|}('/$2',[${3:Controller Name}::class,'${4:Method Name}'])${5:->name('$6')};",
],
"description": "Create Route "
"React component": {
"prefix": "rfc",
"body": [
"export default function $1(){",
" return (",
" $2",
" );",
"}"
],
"description": "React functional component"
"function with Request ": {
"prefix": "fr",
"body": [
"function ${1:ফাংশনের নাম লেখ}(${2|Request $request|}){",
" return $3;",
"}"
],
"description": "create controller function"
"Create enum class": {
"prefix": "enum",
"body": [
"<?php",
"namespace App\\Enums;\n",
"enum $1: string",
"{",
"\tcase $2 = '$3';",
"\t$0",
"}"
],
"description": "Create enum class"
},
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is for creating $fillable array in Laravel modal