“Convenções de nomeação de Laravel” Respostas de código

Convenções de nomeação de Laravel

Gegasoft uses the following name conventions for laravel
=============================================================
Variables	=>	camelCase	=>	$articlesWithAuthor
Collection Variable	=>	descriptive, plural	=>	$activeUsers = User::active()->get()
Object Variable	=>	descriptive, singular	=>	$activeUser = User::active()->first()
View	=>	snake_case	=>	show_filtered.blade.php
Controllers	=>	singular, ProperCase	=>	ArticleController
Model Name	=>	singular, ProperCase	=>	User, FollowingRequest
Model attribute/property	=>	snake_case	=>	$model->created_at
Method	=>	camelCase	=>	getAll
Method in resource controller	=>	table	=>	store
Method in test class	=>	camelCase	=>	testGuestCannotSeeArticle
hasOne/belongsTo relation	=>	singular	=>	articleComment
Other relations	=>	plural	=>	articleComments
Table Name =>	plural	=>	article_comments
Table column	=>	snake_case without model name	=>	meta_title
Route	=>	plural	=>	articles/1
Named route	=>	snake_case with dot notation	=>	users.show_active
Primary key	=>	-	=>	id
Foreign key	=>	singular model name with _id suffix	=>	article_id
Pivot table	=>	singular model names in alphabetical order	=>	article_user
Migration	=>	-	=>	2017_01_01_000000_create_articles_table
Config and language files index	=>	snake_case	=>	articles_enabled
Config	=>	snake_case	=>	google_calendar.php
Contract (interface)	=>	adjective or noun	=>	Authenticatable
Trait	=>	adjective	=>	Notifiable
Gegasoft

Melhores práticas de Laravel

$post = Post::find(1);$post->comments()->saveMany([ new Comment(['message' => 'First comment']), new Comment(['message' => 'Second comment']),]);
Zealous Zebra

Respostas semelhantes a “Convenções de nomeação de Laravel”

Perguntas semelhantes a “Convenções de nomeação de Laravel”

Mais respostas relacionadas para “Convenções de nomeação de Laravel” em PHP

Procure respostas de código populares por idioma

Procurar outros idiomas de código