Examples of Traits (21)

Short information about traits

Usually, developers use Traits to have some functionality re-used in a few different PHP classes, like an "include" to the class. It's not a Laravel concept, it's a PHP functionality.
Read more in the official PHP docs.

Repository: monicahq/monica (Github)
★ 13109 Created: Jul 2017 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Traits/AmountFormatter.php
- app/Models/Contact/Debt.php
- resources/views/people/debt/form.blade.php
Repository: koel/koel (Github)
★ 12683 Created: Dec 2015 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Traits/CanFilterByUser.php
- app/Repositories/PlaylistRepository.php
Repository: bytefury/crater (Github)
★ 4133 Created: Nov 2019 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Traits/HasCustomFieldsTrait.php
- app/Models/Expense.php
Repository: pterodactyl/panel (Github)
★ 2612 Created: Dec 2016 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Traits/Services/HasUserLevels.php
- app/Services/Servers/VariableValidatorService.php
Repository: area17/twill (Github)
★ 2381 Created: Jun 2018 Updated: Aug 2021 Laravel version: 8
Files in the example:
- src/Models/Behaviors/HasPresenter.php
- src/Models/Block.php
- src/Models/User.php
Repository: orchidsoftware/platform (Github)
★ 2302 Created: Nov 2016 Updated: Aug 2021 Laravel version: 8
Files in the example:
- src/Screen/CanSee.php
- src/Screen/Cell.php
Repository: laravelio/laravel.io (Github)
★ 1889 Created: May 2016 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Helpers/HasSlug.php
- app/Models/Tag.php
- app/Models/Article.php
- routes/bindings.php
Repository: Bottelet/DaybydayCRM (Github)
★ 1748 Created: Jul 2016 Updated: Jun 2021 Laravel version: 7
Files in the example:
- app/Traits/DeadlineTrait.php
- app/Models/Project.php
- app/Models/Task.php
- app/Models/Lead.php
- resources/views/projects/_sidebar.blade.php
Repository: iluminar/goodwork (Github)
★ 1622 Created: Nov 2017 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Base/Utilities/GetRecipientsTrait.php
- app/Discussion/Observers/DiscussionObserver.php
Repository: HDInnovations/UNIT3D-Community-Edition (Github)
★ 1366 Created: Dec 2017 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Traits/Encryptable.php
- app/Models/Seedbox.php
Repository: spatie/freek.dev (Github)
★ 428 Created: Nov 2017 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Models/Concerns/HasSlug.php
- app/Models/Link.php
- app/Models/Post.php
Repository: agorakit/agorakit (Github)
★ 332 Created: May 2016 Updated: Jun 2021 Laravel version: 8
Files in the example:
- app/Traits/HasStatus.php
- app/File.php
- resources/views/files/file.blade.php
- app/Group.php
- resources/views/groups/group.blade.php
Repository: tighten/novapackages (Github)
★ 202 Created: Feb 2020 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Policies/HandlesPackageAuthorizationTrait.php
- app/Policies/PackagePolicy.php
- app/Policies/ScreenshotPolicy.php
Repository: opendialogai/opendialog (Github)
★ 171 Created: May 2019 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Http/Requests/ConversationObjectRequestTrait.php
- app/Http/Requests/TurnRequest.php
Repository: krayin/laravel-crm (Github)
★ 171 Created: Jun 2021 Updated: Aug 2021 Laravel version: 8
Files in the example:
- packages/Webkul/Admin/src/Traits/Dashboard/Helper.php
- packages/Webkul/Admin/src/Http/Controllers/Admin/DashboardController.php
Repository: LaravelDaily/Laravel-Support-Ticketing (Github)
★ 152 Created: Nov 2019 Updated: Mar 2021 Laravel version: 8
Files in the example:
- app/Traits/Auditable.php
- app/Ticket.php
Repository: pterobilling/pterobilling (Github)
★ 127 Created: Dec 2020 Updated: Aug 2021 Laravel version: 8
Files in the example:
- app/View/Classes/DiscountExpiry.php
- app/Traits/DiscountExpiry.php
- app/Http/Controllers/Store/OrderController.php
Repository: OpenLitterMap/openlittermap-web (Github)
★ 54 Created: Aug 2020 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Traits/FilterTeamMembersTrait.php
- app/Http/Controllers/Teams/TeamsController.php#L175
Repository: academico-sis/academico (Github)
★ 45 Created: Dec 2018 Updated: Aug 2021 Laravel version: 8
Files in the example:
- app/Traits/PeriodSelection.php
- app/Http/Controllers/HomeController.php
Repository: devhub-az/devhub (Github)
★ 18 Created: Dec 2019 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Helpers/HasAuthor.php
- app/Models/Comment.php
- app/Jobs/CreateComment.php
Repository: Senither/ShareX-Media-Server (Github)
★ 9 Created: Oct 2016 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Traits/MediaResource.php
- app/Models/Url.php
- resources/views/url/url-preview.blade.php

Additional resources on traits: