قراردادهای لاراول برای نامگذاری

بخش مربوطه قاعده اسم گذاری ✔️ روش قابل قبول ❌ روش اشتباه
Controller اسامی مفرد ArticleController ArticlesController
Route اسامی جمع articles/1 article/1
Route name روش snake_case همراه با نقاط اتصال users.show_active users.show-active, show-active-users
Model اسامی مفرد User Users
hasOne or belongsTo relationship اسامی مفرد articleComment articleComments, article_comment
All other relationships اسامی جمع articleComments articleComment, article_comments
Table اسامی جمع article_comments article_comment, articleComments
Pivot table نام مدل ها با اسامی مفرد و ترتیب الفبایی article_user user_article, articles_users
Table column روش snake_case بدون اسم مدل meta_title MetaTitle; article_meta_title
Model property روش snake_case $model->created_at $model->createdAt
Foreign key اسامی مفرد model name with _id suffix article_id ArticleId, id_article, articles_id
Primary key – id custom_id
Migration – 2017_01_01_000000_create_articles_table 2017_01_01_000000_articles
Method روش camelCase getAll get_all
Method in resource controller table store saveArticle
Method in test class روش camelCase testGuestCannotSeeArticle test_guest_cannot_see_article
Variable روش camelCase $articlesWithAuthor $articles_with_author
Collection توصیفی و اسامی جمع $activeUsers = User::active()->get() $active, $data
Object توصیفی و اسامی مفرد $activeUser = User::active()->first() $users, $obj
Config and language files index snake_case articles_enabled ArticlesEnabled; articles-enabled
View kebab-case show-filtered.blade.php showFiltered.blade.php, show_filtered.blade.php
Config snake_case google_calendar.php googleCalendar.php, google-calendar.php
Contract (interface) صفت یا اسم AuthenticationInterface Authenticatable, IAuthentication
Trait صفت Notifiable NotificationTrait
Trait (PSR) adjective NotifiableTrait Notification
Enum singular UserType UserTypes, UserTypeEnum
FormRequest singular UpdateUserRequest UpdateUserFormRequest, UserFormRequest, UserRequest
Seeder singular UserSeeder UsersSeeder