Skip to content

Commit

Permalink
Add Relations snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
patricksamson committed Jul 20, 2016
1 parent 401b6f8 commit 64edbbc
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Input |
Log |
Mail |
Redirect |
Relation | To create model relationships.
Response |
Route |
Schema | Contains two sub-categories : `Schema::` for snippets related to the database table itself; and `Column::` for snippets related to the columns.
Expand Down
3 changes: 2 additions & 1 deletion messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"1.1.2": "messages/1.1.2.txt",
"1.1.3": "messages/1.1.3.txt",
"1.2.0": "messages/1.2.0.txt",
"1.2.4": "messages/1.2.4.txt"
"1.2.4": "messages/1.2.4.txt",
"1.2.11": "messages/1.2.11.txt"
}
17 changes: 17 additions & 0 deletions messages/1.2.11.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Laravel 5 Snippets for Sublime Text
https://github.com/Lykegenes/laravel-5-snippets


Version 1.2.11
********************************************************************************

#### NEW SNIPPETS

New Route snippets have been added for the get/post/put/delete actions.

New snippets have been added to create model relationships.
They are now available under the `Relation::` trigger keyword.

Happy coding!

Improvements or suggestions? Contribute on GitHub!
11 changes: 11 additions & 0 deletions snippets/Relations/Relation-belongsTo.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<snippet>
<content><![CDATA[
public function ${1:user}()
{
return \$this->belongsTo('${2:App\User}'${3:, '${4:foreign_key}'}${5:, '${6:other_key}'});
}
]]></content>
<tabTrigger>Relation::belongsTo</tabTrigger>
<scope>source.php</scope>
<description>A one-to-one inverse relationship.</description>
</snippet>
11 changes: 11 additions & 0 deletions snippets/Relations/Relation-belongsToMany.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<snippet>
<content><![CDATA[
public function ${1:roles}()
{
return \$this->belongsToMany('${2:App\Role}'${3:, '${4:role_user_table}'}${5:, '${6:user_id}'}${7:, '${8:role_id}'});
}
]]></content>
<tabTrigger>Relation::belongsToMany</tabTrigger>
<scope>source.php</scope>
<description>A many-to-many relationship.</description>
</snippet>
11 changes: 11 additions & 0 deletions snippets/Relations/Relation-hasMany.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<snippet>
<content><![CDATA[
public function ${1:comments}()
{
return \$this->hasMany('${2:App\Comment}'${3:, '${4:foreign_key}'}${5:, '${6:local_key}'});
}
]]></content>
<tabTrigger>Relation::hasMany</tabTrigger>
<scope>source.php</scope>
<description>A one-to-many relationship.</description>
</snippet>
11 changes: 11 additions & 0 deletions snippets/Relations/Relation-hasManyThrough.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<snippet>
<content><![CDATA[
public function ${1:comments}()
{
return \$this->hasManyThrough('${2:App\Comment}', ${3:App\Post});
}
]]></content>
<tabTrigger>Relation::hasManyThrough</tabTrigger>
<scope>source.php</scope>
<description>A Has Many Through relationship.</description>
</snippet>
11 changes: 11 additions & 0 deletions snippets/Relations/Relation-hasOne.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<snippet>
<content><![CDATA[
public function ${1:user}()
{
return \$this->hasOne('${2:App\User}'${3:, '${4:foreign_key}'}${5:, '${6:local_key}'});
}
]]></content>
<tabTrigger>Relation::hasOne</tabTrigger>
<scope>source.php</scope>
<description>A one-to-one relationship.</description>
</snippet>

0 comments on commit 64edbbc

Please sign in to comment.