Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 160c6e5

Browse files
authored
Merge pull request #11 from MrEduar/master
Compatibility with Laravel 8 and Improved Relationships Dockblocks
2 parents c57b5f1 + fec8d5a commit 160c6e5

File tree

1 file changed

+42
-7
lines changed

1 file changed

+42
-7
lines changed

snippets/model.json

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,69 +145,104 @@
145145
"Laravel Model: One to One Relationship": {
146146
"prefix": "Model::oo",
147147
"body": [
148+
"/**",
149+
" * Get the $1 associated with the ${TM_FILENAME_BASE}",
150+
" *",
151+
" * @return \\Illuminate\\Database\\Eloquent\\Relations\\HasOne",
152+
" */",
148153
"public function $1()",
149154
"{",
150-
"\treturn \\$this->hasOne('App\\\\$0');",
155+
"\treturn \\$this->hasOne($0::class);",
151156
"}"
152157
],
153158
"description": "One to One: Define a One to One relationship within your model."
154159
},
155160
"Laravel Model: Belongs To Relationship": {
156161
"prefix": "Model::bt",
157162
"body": [
163+
"/**",
164+
" * Get the $1 that owns the ${TM_FILENAME_BASE}",
165+
" *",
166+
" * @return \\Illuminate\\Database\\Eloquent\\Relations\\BelongsTo",
167+
" */",
158168
"public function $1()",
159169
"{",
160-
"\treturn \\$this->belongsTo('App\\\\$0');",
170+
"\treturn \\$this->belongsTo($0::class);",
161171
"}"
162172
],
163173
"description": "Belongs To: Define a Belongs To relationship within your model."
164174
},
165175
"Laravel Model: One to Many": {
166176
"prefix": "Model::om",
167177
"body": [
178+
"/**",
179+
" * Get all of the $1 for the ${TM_FILENAME_BASE}",
180+
" *",
181+
" * @return \\Illuminate\\Database\\Eloquent\\Relations\\HasMany",
182+
" */",
168183
"public function $1()",
169184
"{",
170-
"\treturn \\$this->hasMany('App\\\\$0');",
185+
"\treturn \\$this->hasMany($0::class);",
171186
"}"
172187
],
173188
"description": "One to Many: Define a One to Many relationship within your model."
174189
},
175190
"Laravel Model: Many to Many": {
176191
"prefix": "Model::mm",
177192
"body": [
193+
"/**",
194+
" * The $1 that belong to the ${TM_FILENAME_BASE}",
195+
" *",
196+
" * @return \\Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany",
197+
" */",
178198
"public function $1()",
179199
"{",
180-
"\treturn \\$this->belongsToMany('App\\\\$0');",
200+
"\treturn \\$this->belongsToMany($0::class);",
181201
"}"
182202
],
183203
"description": "Many to Many: Define a Many to Many relationship within your model."
184204
},
185205
"Laravel Model: Belongs to Many": {
186206
"prefix": "Model::btm",
187207
"body": [
208+
"/**",
209+
" * The $1 that belong to the ${TM_FILENAME_BASE}",
210+
" *",
211+
" * @return \\Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany",
212+
" */",
188213
"public function $1()",
189214
"{",
190-
"\treturn \\$this->belongsToMany('App\\\\$0');",
215+
"\treturn \\$this->belongsToMany($0::class);",
191216
"}"
192217
],
193218
"description": "Belongs to Many: Define a Belongs to Many relationship within your model."
194219
},
195220
"Laravel Model: Has Many Through": {
196221
"prefix": "Model::hmt",
197222
"body": [
223+
"/**",
224+
" * Get all of the $1 for the ${TM_FILENAME_BASE}",
225+
" *",
226+
" * @return \\Illuminate\\Database\\Eloquent\\Relations\\HasManyThrough",
227+
" */",
198228
"public function $1()",
199229
"{",
200-
"\treturn \\$this->hasManyThrough('App\\\\$0');",
230+
"\treturn \\$this->hasManyThrough($0::class);",
201231
"}"
202232
],
203233
"description": "Has Many Through: Define a Has Many Through relationship within your model."
204234
},
205235
"Laravel Model: Has One Through": {
206236
"prefix": "Model::hot",
207237
"body": [
238+
"/**",
239+
" * Get the $1 associated with the ${TM_FILENAME_BASE}",
240+
" *",
241+
" * @return \\Illuminate\\Database\\Eloquent\\Relations\\HasOneThrough",
242+
" */",
208243
"public function $1()",
209244
"{",
210-
"\treturn \\$this->hasOneThrough('App\\\\$2', 'App\\\\$3');",
245+
"\treturn \\$this->hasOneThrough($2::class, $3::class);",
211246
"}"
212247
],
213248
"description": "Has One Through: Define a Has One Through relationship within your model. (5.8+)"

0 commit comments

Comments
 (0)