Skip to content

Instantly share code, notes, and snippets.

@OwenMelbz
Created March 21, 2017 19:12
Show Gist options
  • Save OwenMelbz/85fa26f5ee1c778e89e644bd0ca4d98a to your computer and use it in GitHub Desktop.
Save OwenMelbz/85fa26f5ee1c778e89e644bd0ca4d98a to your computer and use it in GitHub Desktop.
My snippets.cson
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting
# tab.
#
# An example CoffeeScript snippet to expand log to console.log:
#
# '.source.coffee':
# 'Console log':
# 'prefix': 'log'
# 'body': 'console.log $1'
#
# Each scope (e.g. '.source.coffee' above) can only be declared once.
#
# This file uses CoffeeScript Object Notation (CSON).
# If you are unfamiliar with CSON, you can read more about it in the
# Atom Flight Manual:
# https://atom.io/docs/latest/using-atom-basic-customization#cson
'.source.sass, .source.css.sass, .source.scss, .source.less':
'box-shadow':
'prefix': 'boxs'
'body': 'box-shadow:'
'.text.html':
'Basic Placeholder Image':
'prefix': 'placeholder'
'body': '<img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=${3}&w=${1}&h=${2}" alt="Decorative Image" aria-hidden="true" role="presentation" />${5}'
'.php':
'Basic Decorative Image':
'prefix': 'ariaalt'
'body': 'alt="decorative image" role="presentation" aria-hidden="true"'
'Crud Field':
'prefix': 'crudfield'
'body': '$this->crud->addField([\n \'name\' => \'${1}\',\n \'label\' => \'${2}\',\n \'type\' => \'${3}\'\n]);${4}'
'Crud Column':
'prefix': 'crudcolumn'
'body': '$this->crud->addColumn([\n \'name\' => \'${1}\',\n \'label\' => \'${2}\',\n \'type\' => \'${3}\'\n]);${4}'
'.php':
'Laravel Test Case':
'prefix': 'testcase'
'body': """
<?php
use Illuminate\\\\Foundation\\\\Testing\\\\WithoutMiddleware;
use Illuminate\\\\Foundation\\\\Testing\\\\DatabaseMigrations;
use Illuminate\\\\Foundation\\\\Testing\\\\DatabaseTransactions;
class $1Test extends TestCase
{
use DatabaseMigrations;
$2
}
"""
'PHP Unit Test':
'prefix': 'test'
'body': """
/** @test */
function $1()
{
$2
}
"""
'Define a singleton service':
'prefix': 'singleton'
'body': """
$this->app->singleton($1, function ($app) {
$2
});
"""
'Service container binding':
'prefix': 'bind'
'body': """
$this->app->bind($1, function ($app) {
$2
});
"""
'Define an alias for a service':
'prefix': 'alias'
'body': """
$this->app->alias('${1:abstract}', '${2:alias}');
"""
'Validation in the controller':
'prefix': 'validate'
'body': """
$this->validate(request(), [
$1
]);
"""
'Json Response':
'prefix': 'rjson'
'body': """
response()->json($1);
"""
'View With':
'prefix': 'vieww'
'body': """
view('$1')${2:->with([$3])};
"""
'View':
'prefix': 'view'
'body': """
view('$1', [$2]);
"""
'Laravel Factory Definition':
'prefix': 'factory'
'body': """
$factory->define(App\\\\$1::class, function (Faker\\\\Generator $faker) {
return [
$2
];
});
"""
'Laravel Factory State Definition':
'prefix': 'factory:state'
'body': """
$factory->state(App\\\\$1::class, '${2:state}', function (Faker\\\\Generator $faker) {
return [
$3
];
});
"""
'"Has One" Relationship':
'prefix': 'hasone'
'body': """
public function $1()
{
return $this->hasOne($2::class);
}
"""
'"Has Many" Relationship':
'prefix': 'hasmany'
'body': """
public function $1()
{
return $this->hasMany($2::class);
}
"""
'"Belongs To" Relationship':
'prefix': 'belongsto'
'body': """
public function $1()
{
return $this->belongsTo($2::class);
}
"""
'"Belongs To Many" Relationship':
'prefix': 'btm'
'body': """
public function $1()
{
return $this->belongsToMany($2::class);
}
"""
'"Has Many Through" Relationship':
'prefix': 'hasmanythrough'
'body': """
public function $1()
{
return $this->hasManyThrough($2::class, $3::class);
}
"""
'Polymorphism: Morph To':
'prefix': 'morphto'
'body': """
public function $1()
{
return $this->morphTo();
}
"""
'Polymorphism: Morph Many':
'prefix': 'morph'
'body': """
public function $1()
{
return $this->morphMany($2::class, '${3:commentable}');
}
"""
'Polymorphism: Morph Many (Long Prefix)':
'prefix': 'morphmany'
'body': """
public function $1()
{
return $this->morphMany($2::class, '${3:commentable}');
}
"""
'Route':
'prefix': 'route'
'body': """
Route::$1('$2', '$3Controller@$4');
"""
'Route Group':
'prefix': 'route:group'
'body': """
Route::group([
$1
], function () {
$2
});
"""
'Key/Value Pairs':
'prefix': 'kv'
'body': """
'$1' => ${2:'$3'},$0
"""
'The $this Keyword':
'prefix': 'this'
'body': '\$this'
'DocBlock Comment Shorter Expansion':
'prefix': '/'
'body': """
/**
* $1
*/
"""
'DocBlock Comment':
'prefix': '/**'
'body': """
/**
* $1
*/
"""
'PHP Anonymous Function':
'prefix': 'func'
'body': """
function ($1) {
$2
}
"""
'PHP Public Function Based on PhpStorm':
'prefix': 'pubf'
'body': """
public function $1($2)
{
$0
}
"""
'PHP Protected Function Based on PhpStorm':
'prefix': 'prof'
'body': """
protected function $1($2)
{
$0
}
"""
'PHP Private Function Based on PhpStorm':
'prefix': 'prif'
'body': """
private function $1($2)
{
$0
}
"""
'PHP Public Function for an interface':
'prefix': 'ipubf'
'body': """
public function $1($2);
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment