Last active
August 3, 2024 16:44
-
-
Save adamwathan/723a3ad31e1586b66450 to your computer and use it in GitHub Desktop.
Eloquent Relationship snippets for Sublime Text
This file contains 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
<snippet> | |
<content><![CDATA[ | |
public function ${1:relationship}() | |
{ | |
return \$this->belongsToMany(${1/^(.+)$/(?1\u$1:)/g}::class, {$2:table}); | |
} | |
]]></content> | |
<!-- Optional: Set a tabTrigger to define how to trigger the snippet --> | |
<tabTrigger>belt</tabTrigger> | |
<!-- Optional: Set a scope to limit where the snippet will trigger --> | |
<scope>source.php</scope> | |
</snippet> |
This file contains 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
<snippet> | |
<content><![CDATA[ | |
public function ${1:relationship}() | |
{ | |
return \$this->belongsTo(${1/^(.+)$/(?1\u$1:)/g}::class); | |
} | |
]]></content> | |
<!-- Optional: Set a tabTrigger to define how to trigger the snippet --> | |
<tabTrigger>belo</tabTrigger> | |
<!-- Optional: Set a scope to limit where the snippet will trigger --> | |
<scope>source.php</scope> | |
</snippet> |
This file contains 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
<snippet> | |
<content><![CDATA[ | |
public function ${1:relationship}() | |
{ | |
return \$this->hasMany(${1/^(.+)$/(?1\u$1:)/g}::class); | |
} | |
]]></content> | |
<!-- Optional: Set a tabTrigger to define how to trigger the snippet --> | |
<tabTrigger>hasm</tabTrigger> | |
<!-- Optional: Set a scope to limit where the snippet will trigger --> | |
<scope>source.php</scope> | |
</snippet> |
This file contains 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
<snippet> | |
<content><![CDATA[ | |
public function ${1:relationship}() | |
{ | |
return \$this->hasOne(${1/^(.+)$/(?1\u$1:)/g}::class); | |
} | |
]]></content> | |
<!-- Optional: Set a tabTrigger to define how to trigger the snippet --> | |
<tabTrigger>haso</tabTrigger> | |
<!-- Optional: Set a scope to limit where the snippet will trigger --> | |
<scope>source.php</scope> | |
</snippet> |
Thanks ! Useful Snippets.
Love it!
Seems to be a bug with replacing the last 's' in hasMany. Strips the last 's' regardless of whether it is the last character or not.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! That's awesome! 👍 Perhaps
belm
instead ofbelt
to follow a pattern.