spacevim/bundle/vim-snippets/UltiSnips/php-laravel.snippets
JIe 2bb7059579
Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
init
2024-08-21 14:17:26 +08:00

271 lines
4.9 KiB
Plaintext

#resource controller
snippet l_rsc "Laravel resource controller" b
/*!
* \class $1
*
* \author ${3:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
class ${1:`!v expand('%:t:r')`} extends ${2:BaseController} {
function __construct() {
}
public function index() {
}
public function create() {
}
public function store() {
}
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
<?php
/*!
* \namespace $1
* \class $2
*
* \author ${3:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace ${1:Services};
use Illuminate\Support\ServiceProvider;
class ${2:`!v expand('%:t:r')`} extends ServiceProvider {
public function register() {
$this->app->bind('$4Service', function ($app) {
return new $5(
$app->make('Repositories\\$6Interface')
);
});
}
}
endsnippet
#repository service provider
snippet l_rsp "Laravel service provider for repository" b
<?php
/*!
* \namespace $2
* \class $3
*
* \author ${4:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace ${2:Repositories\\${1:}};
use Entities\\$1;
use $2\\$1Repository;
use Illuminate\Support\ServiceProvider;
class ${3:`!v expand('%:t:r')`} extends ServiceProvider {
/*!
* \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
<?php
/*!
* \namespace $1
* \class $2
*
* \author ${3:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace ${1:Entities};
class ${2:`!v expand('%:t:r')`} extends \Eloquent {
protected $table = '${4:`!p snip.rv = t[2].lower()`}';
public $timestamps = ${5:false};
protected $hidden = [$6];
protected $guarded = [${7:'id'}];
}
endsnippet
#abstract repository
snippet l_ar "Laravel abstract Repository" b
<?php
/*!
* \namespace $1
* \class $2
* \implements $3
*
* \author ${4:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace ${1:Repositories};
use Illuminate\Database\Eloquent\Model;
abstract class ${2:`!v expand('%:t:r')`} implements ${3:BaseRepositoryInterface} {
protected $model;
/*!
* \fn __construct
*
* \brief Take the model
*/
public function __construct(Model $model) {
$this->model = $model;
}
/*!
* \fn all
*
* \return Illuminate\Database\Eloquent\Collection
*/
public function all($columns = ['*']) {
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
*/
public function find($id, $columns = ['*']) {
return $this->model->find($id, $columns);
}
}
endsnippet
#repository
snippet l_r "Laravel Repository" b
<?php
/*!
* \namespace $1
* \class $3
* \implements $4
*
* \author ${5:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace ${1:Repositories\\$2};
class ${3:`!v expand('%:t:r')`} extends \\$6 implements ${4:$3RepositoryInterface} {
$7
}
endsnippet
#service
snippet l_s "Laravel Service" b
<?php
/*!
* \namespace $1
* \class $2
*
* \author ${6:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace Services\\$1;
use ${3:Repositories\\${4:Interface}};
class ${2:`!v expand('%:t:r')`} {
protected $${5:repo};
/*!
* \fn __construct
*/
public function __construct($4 $repo) {
$this->$5 = $repo;
}
}
endsnippet
#facade
snippet l_f "Laravel Facade" b
<?php
/*!
* \namespace $1
* \class $2
*
* \author ${5:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace ${1:Services};
use \Illuminate\Support\Facades\Facade;
class ${2:`!v expand('%:t:r')`} extends Facade {
/*!
* \fn getFacadeAccessor
*
* \return string
*/
protected static function getFacadeAccessor() { return '${4:$3Service}'; }
}
endsnippet