Examples of Local scopes (11)

Short information about local scopes

Local scopes allow you to define a common condition for Eloquent models that you may easily re-use throughout your application. For example, you may need to frequently retrieve all users that are considered "popular". To define a scope, create an Eloquent model method like function scopeCondition().
Read more in the official Laravel docs.

Repository: bytefury/crater (Github)
★ 4133 Created: Nov 2019 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Models/PaymentMethod.php
- app/Http/Controllers/V1/Payment/PaymentMethodsController.php
Repository: laravelio/laravel.io (Github)
★ 1889 Created: May 2016 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Models/Thread.php
- app/Http/Controllers/Forum/ThreadsController.php
Repository: guillaumebriday/laravel-blog (Github)
★ 1317 Created: Dec 2016 Updated: May 2021 Laravel version: 8
Files in the example:
- app/Models/Comment.php
- app/Http/Controllers/Admin/ShowDashboard.php
Repository: inertiajs/pingcrm (Github)
★ 1159 Created: Mar 2019 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Models/Contact.php
- app/Http/Controllers/ContactsController.php
Repository: Kovah/LinkAce (Github)
★ 822 Created: Aug 2018 Updated: Jun 2021 Laravel version: 8
Files in the example:
- app/Models/Link.php
- app/Http/Controllers/App/DashboardController.php
Repository: spatie/spatie.be (Github)
★ 306 Created: Oct 2020 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Models/Ad.php
- app/Jobs/RandomizeAdsOnGitHubRepositoriesJob.php
Repository: officelifehq/officelife (Github)
★ 217 Created: Jan 2019 Updated: Aug 2021 Laravel version: 8
Files in the example:
- app/Models/Company/Task.php
- app/Http/ViewHelpers/Dashboard/DashboardMeViewHelper.php
Repository: LaravelDaily/Laravel-Support-Ticketing (Github)
★ 152 Created: Nov 2019 Updated: Mar 2021 Laravel version: 8
Files in the example:
- app/Ticket.php
- app/Http/Controllers/Admin/TicketsController.php
Repository: christophrumpel/larastreamers (Github)
★ 82 Created: May 2021 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Models/Stream.php
- app/Http/Controllers/PageHomeController.php
Repository: driesvints/driesvints.com (Github)
★ 67 Created: May 2020 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Models/Post.php
- app/Http/Controllers/BlogController.php
Repository: PHPJunior/mtube (Github)
★ 41 Created: Jul 2021 Updated: Aug 2021 Laravel version: 8
Files in the example:
- app/Models/Channel/Comment.php
- app/Http/Livewire/Frontend/Components/Comment.php

Additional resources on local scopes: