mirror of
1
0
Fork 0
ultimate-vim/sources_non_forked/vim-snippets/UltiSnips/php-laravel.snippets

271 lines
4.9 KiB
Plaintext
Raw Normal View History

2015-01-18 07:58:28 -05:00
#resource controller
snippet l_rsc "Laravel resource controller" b
/*!
2015-07-13 06:22:46 -04:00
* \class $1
2015-01-18 07:58:28 -05:00
*
2015-07-13 06:22:46 -04:00
* \author ${3:`!v g:snips_author`}
2015-01-18 07:58:28 -05:00
* \date `!v strftime('%d-%m-%y')`
*/
2015-07-13 06:22:46 -04:00
class ${1:`!v expand('%:t:r')`} extends ${2:BaseController} {
2015-02-04 05:43:54 -05:00
function __construct() {
}
2015-01-18 07:58:28 -05:00
public function index() {
}
public function create() {
}
2015-07-13 06:22:46 -04:00
public function store() {
2015-01-18 07:58:28 -05:00
}
public function show($id) {
}
public function edit($id) {
}
public function update($id) {
}
public function destroy($id) {
}
}
endsnippet
#service service provider
snippet l_ssp "Laravel service provider for service" b
2016-05-14 07:57:54 -04:00
<?php
2015-01-18 07:58:28 -05:00
/*!
2015-07-13 06:22:46 -04:00
* \namespace $1
* \class $2
2015-01-18 07:58:28 -05:00
*
* \author ${3:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
2015-07-13 06:22:46 -04:00
namespace ${1:Services};
2015-01-18 07:58:28 -05:00
use Illuminate\Support\ServiceProvider;
2015-07-13 06:22:46 -04:00
class ${2:`!v expand('%:t:r')`} extends ServiceProvider {
2015-01-18 07:58:28 -05:00
public function register() {
2017-02-11 08:01:38 -05:00
$this->app->bind('$4Service', function ($app) {
return new $5(
$app->make('Repositories\\$6Interface')
2015-01-18 07:58:28 -05:00
);
});
}
}
endsnippet
#repository service provider
snippet l_rsp "Laravel service provider for repository" b
2016-05-14 07:57:54 -04:00
<?php
2015-01-18 07:58:28 -05:00
/*!
2015-07-13 06:22:46 -04:00
* \namespace $2
* \class $3
2015-01-18 07:58:28 -05:00
*
* \author ${4:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
2015-07-13 06:22:46 -04:00
namespace ${2:Repositories\\${1:}};
2015-01-18 07:58:28 -05:00
use Entities\\$1;
use $2\\$1Repository;
use Illuminate\Support\ServiceProvider;
2015-07-13 06:22:46 -04:00
class ${3:`!v expand('%:t:r')`} extends ServiceProvider {
2015-01-18 07:58:28 -05:00
/*!
* \var defer
* \brief Defer service
*/
protected $defer = ${5:true};
public function register() {
$this->app->bind('$2\\$1Interface', function($app) {
return new $1Repository(new $1());
});
}
/*!
* \brief If $defer == true need this fn
*/
public function provides() {
return ['$2\\$1Interface'];
}
}
endsnippet
#model
snippet l_md "Laravel simple model" b
2016-05-14 07:57:54 -04:00
<?php
2015-01-18 07:58:28 -05:00
/*!
2015-07-13 06:22:46 -04:00
* \namespace $1
* \class $2
2015-01-18 07:58:28 -05:00
*
* \author ${3:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
2015-07-13 06:22:46 -04:00
namespace ${1:Entities};
2015-01-18 07:58:28 -05:00
2015-07-13 06:22:46 -04:00
class ${2:`!v expand('%:t:r')`} extends \Eloquent {
2015-01-18 07:58:28 -05:00
protected $table = '${4:`!p snip.rv = t[2].lower()`}';
2015-02-04 05:43:54 -05:00
public $timestamps = ${5:false};
2015-01-18 07:58:28 -05:00
2017-02-11 08:01:38 -05:00
protected $hidden = [$6];
2015-01-18 07:58:28 -05:00
2016-11-09 12:22:55 -05:00
protected $guarded = [${7:'id'}];
2015-01-18 07:58:28 -05:00
}
endsnippet
#abstract repository
snippet l_ar "Laravel abstract Repository" b
2016-05-14 07:57:54 -04:00
<?php
2015-01-18 07:58:28 -05:00
/*!
2015-07-13 06:22:46 -04:00
* \namespace $1
* \class $2
* \implements $3
2015-01-18 07:58:28 -05:00
*
* \author ${4:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
2015-07-13 06:22:46 -04:00
namespace ${1:Repositories};
2015-01-18 07:58:28 -05:00
use Illuminate\Database\Eloquent\Model;
2015-07-13 06:22:46 -04:00
abstract class ${2:`!v expand('%:t:r')`} implements ${3:BaseRepositoryInterface} {
2015-01-18 07:58:28 -05:00
protected $model;
/*!
* \fn __construct
*
* \brief Take the model
*/
public function __construct(Model $model) {
$this->model = $model;
}
/*!
* \fn all
*
* \return Illuminate\Database\Eloquent\Collection
*/
2016-11-09 12:22:55 -05:00
public function all($columns = ['*']) {
2015-01-18 07:58:28 -05:00
return $this->model->all()->toArray();
}
/*!
* \fn create
*
* \return Illuminate\Database\Eloquent\Model
*/
public function create(array $attributes) {
return $this->model->create($attributes);
}
/*!
* \fn destroy
*
* \return int
*/
public function destroy($ids) {
return $this->model->destroy($ids);
}
/*!
* \fn find
*
* \return mixed
*/
2016-11-09 12:22:55 -05:00
public function find($id, $columns = ['*']) {
2015-01-18 07:58:28 -05:00
return $this->model->find($id, $columns);
}
}
endsnippet
#repository
snippet l_r "Laravel Repository" b
2016-05-14 07:57:54 -04:00
<?php
2015-01-18 07:58:28 -05:00
/*!
2015-07-13 06:22:46 -04:00
* \namespace $1
* \class $3
* \implements $4
2015-01-18 07:58:28 -05:00
*
* \author ${5:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
2017-02-11 08:01:38 -05:00
namespace ${1:Repositories\\$2};
2015-01-18 07:58:28 -05:00
2017-02-11 08:01:38 -05:00
class ${3:`!v expand('%:t:r')`} extends \\$6 implements ${4:$3RepositoryInterface} {
$7
2015-01-18 07:58:28 -05:00
}
endsnippet
#service
snippet l_s "Laravel Service" b
2016-05-14 07:57:54 -04:00
<?php
2015-01-18 07:58:28 -05:00
/*!
2015-07-13 06:22:46 -04:00
* \namespace $1
* \class $2
2015-01-18 07:58:28 -05:00
*
2015-07-13 06:22:46 -04:00
* \author ${6:`!v g:snips_author`}
2015-01-18 07:58:28 -05:00
* \date `!v strftime('%d-%m-%y')`
*/
2017-02-11 08:01:38 -05:00
namespace Services\\$1;
2015-01-18 07:58:28 -05:00
2015-07-13 06:22:46 -04:00
use ${3:Repositories\\${4:Interface}};
2015-01-18 07:58:28 -05:00
2015-07-13 06:22:46 -04:00
class ${2:`!v expand('%:t:r')`} {
protected $${5:repo};
2015-01-18 07:58:28 -05:00
/*!
* \fn __construct
*/
2015-07-13 06:22:46 -04:00
public function __construct($4 $repo) {
$this->$5 = $repo;
2015-01-18 07:58:28 -05:00
}
}
endsnippet
#facade
snippet l_f "Laravel Facade" b
2016-05-14 07:57:54 -04:00
<?php
2015-01-18 07:58:28 -05:00
/*!
2015-07-13 06:22:46 -04:00
* \namespace $1
* \class $2
2015-01-18 07:58:28 -05:00
*
2015-07-13 06:22:46 -04:00
* \author ${5:`!v g:snips_author`}
2015-01-18 07:58:28 -05:00
* \date `!v strftime('%d-%m-%y')`
*/
2015-07-13 06:22:46 -04:00
namespace ${1:Services};
2015-01-18 07:58:28 -05:00
use \Illuminate\Support\Facades\Facade;
2015-07-13 06:22:46 -04:00
class ${2:`!v expand('%:t:r')`} extends Facade {
2015-01-18 07:58:28 -05:00
/*!
* \fn getFacadeAccessor
*
* \return string
*/
2017-02-11 08:01:38 -05:00
protected static function getFacadeAccessor() { return '${4:$3Service}'; }
2015-01-18 07:58:28 -05:00
}
endsnippet