Skip to content

Latest commit

 

History

History
518 lines (314 loc) · 6.51 KB

snippet-reference.markdown

File metadata and controls

518 lines (314 loc) · 6.51 KB

Snippet Reference

This file is generated from the source snippets/*.cson files.


Define a singleton service

File: application.cson

Shortcut: singleton + tab

$this->app->singleton($1, function ($app) {
    $2
});

Service container binding

File: application.cson

Shortcut: bind + tab

$this->app->bind($1, function ($app) {
    $2
});

Define an alias for a service

File: application.cson

Shortcut: alias + tab

$this->app->alias('${1:abstract}', '${2:alias}');

Validation in the controller

File: controller.cson

Shortcut: validate + tab

$this->validate(request(), [
    $1
]);

Json Response

File: controller.cson

Shortcut: rjson + tab

response()->json($1);

View With

File: controller.cson

Shortcut: vieww + tab

view('$1')${2:->with([$3])};

View

File: controller.cson

Shortcut: view + tab

view('$1', [$2]);

Laravel Factory Definition

File: database.cson

Shortcut: factory + tab

$factory->define(App\$1::class, function (Faker\Generator $faker) {
    return [
        $2
    ];
});

Laravel Factory State Definition

File: database.cson

Shortcut: factory:state + tab

$factory->state(App\$1::class, '${2:state}', function (Faker\Generator $faker) {
    return [
        $3
    ];
});

"Has One" Relationship

File: eloquent.cson

Shortcut: hasone + tab

public function $1()
{
    return $this->hasOne($2::class);
}

"Has Many" Relationship

File: eloquent.cson

Shortcut: hasmany + tab

public function $1()
{
    return $this->hasMany($2::class);
}

"Belongs To" Relationship

File: eloquent.cson

Shortcut: belongsto + tab

public function $1()
{
    return $this->belongsTo($2::class);
}

"Belongs To Many" Relationship

File: eloquent.cson

Shortcut: btm + tab

public function $1()
{
    return $this->belongsToMany($2::class);
}

"Has Many Through" Relationship

File: eloquent.cson

Shortcut: hasmanythrough + tab

public function $1()
{
    return $this->hasManyThrough($2::class, $3::class);
}

Polymorphism: Morph To

File: eloquent.cson

Shortcut: morphto + tab

public function $1()
{
    return $this->morphTo();
}

Polymorphism: Morph Many

File: eloquent.cson

Shortcut: morph + tab

public function $1()
{
    return $this->morphMany($2::class, '${3:commentable}');
}

Polymorphism: Morph Many (Long Prefix)

File: eloquent.cson

Shortcut: morphmany + tab

public function $1()
{
    return $this->morphMany($2::class, '${3:commentable}');
}

Ascii Logo

File: fun.cson

Shortcut: laravel:logo + tab

:/:::::::+.
.+-      `+:
 .+-      `//`
  -+:       :/`            `---::-:-
   -+:       -+.            -/.    .:.
    -+:       .+:            `/:`   `:/`
     -+:       `//`         ``./+::::::.
      -o:       `:+.`..-::::::-..:/`
       -o:``..-::/+++:-.```       ./-
        -+//::-.```-+:             `:/`
                    .+/`       `..:/+/:
                     `++``.-:/+//:-`
                      `/++/:-.

Key/Value Pairs

File: php.cson

Shortcut: kv + tab

'$1' => ${2:'$3'},$0

The $this Keyword

File: php.cson

Shortcut: this + tab

$this

DocBlock Comment Shorter Expansion

File: php.cson

Shortcut: / + tab

/**
 * $1
 */

DocBlock Comment

File: php.cson

Shortcut: /** + tab

/**
 * $1
 */

PHP Anonymous Function

File: php.cson

Shortcut: func + tab

function ($1) {
    $2
}

PHP Public Function Based on PhpStorm

File: php.cson

Shortcut: pubf + tab

public function $1($2)
{
    $0
}

PHP Protected Function Based on PhpStorm

File: php.cson

Shortcut: prof + tab

protected function $1($2)
{
    $0
}

PHP Private Function Based on PhpStorm

File: php.cson

Shortcut: prif + tab

private function $1($2)
{
    $0
}

PHP Public Function for an interface

File: php.cson

Shortcut: ipubf + tab

public function $1($2);

Route

File: routes.cson

Shortcut: route + tab

Route::$1('$2', '$3Controller@$4');

Route Group

File: routes.cson

Shortcut: route:group + tab

Route::group([
    $1
], function () {
    $2
});

Laravel Test Case

File: tests.cson

Shortcut: testcase + tab

use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;

class $1Test extends TestCase
{
    $2
}

PHP Unit Test

File: tests.cson

Shortcut: test + tab

/** @test */
function $1()
{
    $2
}

Shebang (Longer Shortcut)

File: util.cson

Shortcut: shebang + tab

#!/usr/bin/env ${1:bash}$0

Shebang

File: util.cson

Shortcut: #! + tab

#!/usr/bin/env ${1:bash}$0

To regenerate this document run: node docs.js.