Last active
August 22, 2017 13:04
-
-
Save vertisan/232de9bd88aa693acbae390435bb41f0 to your computer and use it in GitHub Desktop.
Sublime Text 3 - Laravel Snippets (used PHP 7.1!)
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
<!-- Laravel Model - Custom connection --> | |
<snippet> | |
<content><![CDATA[ | |
/** | |
* Connection type for model | |
* @var string | |
*/ | |
protected \$connection = '${1:name_of_connection}'; | |
]]></content> | |
<tabTrigger>laravel:connection</tabTrigger> | |
<tabTrigger>laravel:model:connection</tabTrigger> | |
<scope>source.php</scope> | |
</snippet> |
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
<!-- Laravel Model - Fillable field --> | |
<snippet> | |
<content><![CDATA[ | |
/** | |
* Field for mass-fill | |
* @var array | |
*/ | |
protected $fillable = [ | |
'${1:this}' | |
]; | |
]]></content> | |
<tabTrigger>laravel:fillable</tabTrigger> | |
<tabTrigger>laravel:model:fillable</tabTrigger> | |
<scope>source.php</scope> | |
</snippet> |
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
<!-- Laravel Model - Custom Primary Key --> | |
<snippet> | |
<content><![CDATA[ | |
/** | |
* Custom primary key for model | |
* @var string | |
*/ | |
public \$primaryKey = '${1:custom_key}'; | |
]]></content> | |
<tabTrigger>laravel:primarykey</tabTrigger> | |
<tabTrigger>laravel:model:primarykey</tabTrigger> | |
<scope>source.php</scope> | |
</snippet> |
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
<!-- Laravel Model - Relation method --> | |
<snippet> | |
<content><![CDATA[ | |
/** | |
* ${2:Relation description} | |
* | |
* @return ${7:\Illuminate\Database\Eloquent\Relations\HasMany} | |
*/ | |
public function ${1:relation}() : ${7:\Illuminate\Database\Eloquent\Relations\HasMany} | |
{ | |
return \$this->${3:hasMany}('${4:relatedModel}', '${5:relatedModelKey}', '${6:id}'); | |
} | |
]]></content> | |
<tabTrigger>laravel:relation</tabTrigger> | |
<tabTrigger>laravel:model:relation</tabTrigger> | |
<scope>source.php</scope> | |
</snippet> |
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
<!-- Laravel Model - Scope --> | |
<snippet> | |
<content><![CDATA[ | |
/** | |
* ${2:Scope description} | |
* | |
* @param \Illuminate\Database\Eloquent\Builder \$query | |
* @return \Illuminate\Database\Eloquent\Builder | |
*/ | |
public function scope${1:NameOfScope}(\$query) | |
{ | |
return \$query->$3; | |
} | |
]]></content> | |
<tabTrigger>laravel:scope</tabTrigger> | |
<tabTrigger>laravel:model:scope</tabTrigger> | |
<scope>source.php</scope> | |
</snippet> |
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
<!-- Laravel Model - Database table for model --> | |
<snippet> | |
<content><![CDATA[ | |
/** | |
* Database table for model | |
* @var string | |
*/ | |
protected \$table = '${1:table}'; | |
]]></content> | |
<tabTrigger>laravel:table</tabTrigger> | |
<tabTrigger>laravel:model:table</tabTrigger> | |
<scope>source.php</scope> | |
</snippet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment