Skip to content

Instantly share code, notes, and snippets.

@DeOGe
Last active September 25, 2018 03:33
Show Gist options
  • Save DeOGe/cc48c4927bc7f47a722dea70a4ecbba6 to your computer and use it in GitHub Desktop.
Save DeOGe/cc48c4927bc7f47a722dea70a4ecbba6 to your computer and use it in GitHub Desktop.
{
// Place your snippets for html 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, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"Repository": {
"prefix": ":repo",
"description": "Repository",
"body": [
"<?php",
"",
"namespace App\\Modules\\\\${1:Module}\\Repositories;",
"",
"use App\\Modules\\\\${1:Module}\\Models\\\\${2:Resource};",
"",
"class ${TM_FILENAME/(.+)\\..+|.*/$1/} extends ${2:Resource}",
"{",
"\t//$4",
"}",
"",
]
},
"Resource": {
"prefix": ":rsrc",
"description": "Resource",
"body": [
"<?php",
"",
"namespace App\\Modules\\\\${1:Module}\\Http\\Resources;",
"",
"use Damnyan\\Cmn\\Abstracts\\AbstractResource as Resource;",
"",
"class ${TM_FILENAME/(.+)\\..+|.*/$1/} extends Resource",
"{",
"\t/**",
"\t* Transform the resource into an array.",
"\t*",
"\t* @param \\Illuminate\\Http\\Request",
"\t* @return array",
"\t*/",
"\tpublic function toArray(\\$request)",
"\t{",
"\t\treturn parent::toArray(\\$request);",
"\t}",
"}",
"",
]
},
"ResourceCollection": {
"prefix": ":rsrs",
"description": "Resource Collection",
"body": [
"<?php",
"",
"namespace App\\Modules\\\\${1:Module}\\Http\\Resources;",
"",
"use App\\Modules\\\\${1:Module}\\Http\\Resources\\\\${2:Resource};",
"use Damnyan\\Cmn\\Abstracts\\AbstractResourceCollection as ResourceCollection;",
"",
"class ${TM_FILENAME/(.+)\\..+|.*/$1/} extends ResourceCollection",
"{",
"\t/**",
"\t* Transform the resource collection into an array.",
"\t*",
"\t* @param \\Illuminate\\Http\\Request \\$request request",
"\t* @return array",
"\t*/",
"\tpublic function toArray(\\$request)",
"\t{",
"\t\treturn ${2:Resource}::collection(\\$this->collection);",
"\t}",
"}",
"",
]
},
"Request": {
"prefix": ":rqst",
"description": "Request",
"body": [
"<?php",
"",
"namespace App\\Modules\\\\${1:Module}\\Http\\Requests;",
"",
"use Damnyan\\Cmn\\Abstracts\\ApiRequest;",
"",
"class ${TM_FILENAME/(.+)\\..+|.*/$1/} extends ApiRequest",
"{",
"\t/**",
"\t* Determine if the user is authorized to make this request.",
"\t*",
"\t* @return bool",
"\t*/",
"\tpublic function authorize()",
"\t{",
"\t\treturn true;",
"\t}",
"",
"\t/**",
"\t* Get the validation rules that apply to the request.",
"\t*",
"\t* @return array",
"\t*/",
"\tpublic function rules()",
"\t{",
"\t\tif (\\$this->method() === 'PUT') {",
"\t\t\treturn [",
"\t\t\t\t$3",
"\t\t\t];",
"\t\t}",
"",
"\t\treturn [",
"\t\t\t$4",
"\t\t];",
"\t}",
"}",
"",
]
},
"Controller": {
"prefix": ":ctrl",
"description": "Controller",
"body": [
"<?php",
"",
"namespace App\\Modules\\\\${1:Module}\\Http\\Controllers;",
"",
"use Illuminate\\Http\\Request;",
"use App\\Http\\Controllers\\Controller;",
"use Damnyan\\Cmn\\Services\\ApiResponse;",
"",
"class ${TM_FILENAME/(.+)\\..+|.*/$1/} extends Controller",
"{",
"\t/**",
"\t* Display a listing of the resource.",
"\t*",
"\t* @return \\Damnyan\\Cmn\\Services\\ApiResponse",
"\t*/",
"\tpublic function index()",
"\t{",
"\t\t//",
"\t}",
"",
"\t/**",
"\t* Store a newly created resource in storage.",
"\t*",
"\t* @param \\Illuminate\\Http\\Request \\$request",
"\t*",
"\t* @return \\Damnyan\\Cmn\\Services\\ApiResponse",
"\t*/",
"\tpublic function store(Request \\$request)",
"\t{",
"\t\t//",
"\t}",
"",
"\t/**",
"\t* Display the specified resource.",
"\t*",
"\t* @param int \\$id",
"\t*",
"\t* @return \\Damnyan\\Cmn\\Services\\ApiResponse",
"\t*/",
"\tpublic function show(\\$id)",
"\t{",
"\t\t//",
"\t}",
"",
"\t/**",
"\t* Update the specified resource in storage.",
"\t*",
"\t* @param \\Illuminate\\Http\\Request \\$request",
"\t* @param int \\$id",
"\t*",
"\t* @return \\Damnyan\\Cmn\\Services\\ApiResponse",
"\t*/",
"\tpublic function update(Request \\$request, \\$id)",
"\t{",
"\t\t//",
"\t}",
"",
"\t/**",
"\t* Remove the specified resource from storage.",
"\t*",
"\t* @param int \\$id",
"\t*",
"\t* @return \\Damnyan\\Cmn\\Services\\ApiResponse",
"\t*/",
"\tpublic function destroy(\\$id)",
"\t{",
"\t\t//",
"\t}",
"}",
"",
]
},
"Model": {
"prefix": ":model",
"description": "Model",
"body": [
"<?php",
"",
"namespace App\\Modules\\\\${1:Module}\\Models;",
"",
"use Damnyan\\Cmn\\Abstracts\\AbstractModel;",
"use Illuminate\\Database\\Eloquent\\SoftDeletes;",
"use Damnyan\\Cmn\\Traits\\Models\\CreatorUpdaterTrait;",
"",
"class ${2:${TM_FILENAME/(.+)\\..+|.*/$1/}} extends AbstractModel",
"{",
"",
"use CreatorUpdaterTrait, SoftDeletes;",
"",
"\t/**",
"\t* The database table used by the model.",
"\t*",
"\t* @var string",
"\t*/",
"\tprotected \\$table = '${3:${TM_FILENAME/(.+)\\..+|.*/${1:/downcase}/}s}';",
"",
"\t/**",
"\t* The resource name used by the model.",
"\t*",
"\t* @var string",
"\t*/",
"\tprotected \\$resourceName = '${4:${TM_FILENAME/(.+)\\..+|.*/$1/}}';",
"",
"\t/**",
"\t* The primary key used by the model.",
"\t*",
"\t* @var string",
"\t*/",
"\tprotected \\$primaryKey = '${5:id}';",
"",
"\t/**",
"\t* The \"type\" of the auto-incrementing ID.",
"\t*",
"\t* @var string",
"\t*/",
"\tprotected \\$keyType = '${6:integer}';",
"",
"\t/**",
"\t* Enables the timestamp in the model",
"\t*",
"\t* @var string",
"\t*/",
"\tpublic \\$timestamps = ${7:false};",
"",
"\t/**",
"\t* The attributes that are mass assignable.",
"\t*",
"\t* @var array",
"\t*/",
"\tprotected \\$fillable = [",
"\t\t${8://}",
"\t];",
"",
"\t/**",
"\t* The attributes excluded from the model's JSON form.",
"\t*",
"\t* @var array",
"\t*/",
"\tprotected \\$hidden = [",
"\t\t${9://}",
"\t];",
"",
"\t/**",
"\t* The attributes that should be mutated to dates.",
"\t*",
"\t* @var array",
"\t*/",
"\tprotected \\$dates = [",
"\t\t'created_at',",
"\t\t'updated_at'",
"\t];",
"}",
"",
]
},
"Route": {
"prefix": ":route",
"description": "Index and Store Routes",
"body": [
"<?php",
"" ,
"Route::group(",
"\t['middleware' => ['${1:role:user:Administrator}']], function () {",
"\t\tRoute::get('\/', '${2:Mng}\\\\${3:Resource}Controller@index');",
"\t\tRoute::post('\/', '${2:Mng}\\\\${3:Resource}Controller@store');",
"\t}",
");",
"",
]
},
"Route Id": {
"prefix": ":routeId",
"description": "Show, Update and Destroy Routes",
"body": [
"<?php",
"" ,
"Route::group(",
"\t['middleware' => ['${1:role:user:Administrator}']], function () {",
"\t\tRoute::get('\/', '${2:Mng}\\\\${3:Resource}Controller@show');",
"\t\tRoute::put('\/', '${2:Mng}\\\\${3:Resource}Controller@update');",
"\t\tRoute::delete('\/', '${2:Mng}\\\\${3:Resource}Controller@delete');",
"\t}",
");",
"",
]
}
}
@DeOGe
Copy link
Author

DeOGe commented Sep 3, 2018

paste sa HTML at Plaintext

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