aboutsummaryrefslogtreecommitdiff
path: root/vim/bundle/vim-snippets/snippets/laravel.snippets
blob: e7435e3b96528a8d0cf30cd214ae948005cb8b95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
#resource controller
snippet l_rsc
	/*!
	* \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) {
		}
	}
#service service provider
snippet l_ssp
	/*!
	* \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('${4}Service', function ($app) {
				return new ${5}(
					$app->make('Repositories\\${6}Interface')
				);
			});
		}
	}
#repository service provider
snippet l_rsp
	/*!
	* \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'];
		}
	}
#model
snippet l_md
	/*!
	* \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  = array(${6});

		protected $guarded = array(${7:'id'});
	}
#abstract repository
snippet l_ar
	/*!
	* \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 = array('*')) {
				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 = array('*')) {
			return $this->model->find($id, $columns);
		}
	}

#repository
snippet l_r
	/*!
	* \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}
	}
#service
snippet l_s
	/*!
	* \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;
		}
	}
#facade
snippet l_f
	/*!
	* \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:${3}Service}'; }
	}