Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

Code Examples of local scopes

Discover how to use Laravel's local scopes method in real-world applications. Browse 18 examples from popular open-source projects.

18 examples
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.

bytefury/crater

  • 8213
  • Created Nov 2019
  • Updated Aug 2024

Files in this example

  • app/Models/PaymentMethod.php
    • app/Http/Controllers/V1/Payment/PaymentMethodsController.php
View full example

Kovah/LinkAce

  • 3159
  • Created Aug 2018
  • Updated Nov 2025

Files in this example

  • app/Models/Link.php
    • app/Http/Controllers/App/DashboardController.php
View full example

laravelio/laravel.io

  • 2497
  • Created May 2016
  • Updated Nov 2025

Files in this example

  • app/Models/Thread.php
    • app/Http/Controllers/Forum/ThreadsController.php
View full example

inertiajs/pingcrm

  • 2292
  • Created Mar 2019
  • Updated Feb 2025

Files in this example

  • app/Models/Contact.php
    • app/Http/Controllers/ContactsController.php
View full example

guillaumebriday/laravel-blog

  • 1797
  • Created Dec 2016
  • Updated Oct 2024

Files in this example

  • app/Models/Comment.php
    • app/Http/Controllers/Admin/ShowDashboard.php
View full example

officelifehq/officelife

  • 942
  • Created Jan 2019
  • Updated Jul 2024

Files in this example

  • app/Models/Company/Task.php
    • app/Http/ViewHelpers/Dashboard/DashboardMeViewHelper.php
View full example

ploi-deploy/roadmap

  • 527
  • Created May 2022
  • Updated Nov 2025

Files in this example

  • app/Models/Board.php
    • app/Http/Controllers/ProjectController.php
View full example

protonemedia/eddy-server-management

  • 507
  • Created May 2023
  • Updated Aug 2024

Files in this example

  • app/Models/Credentials.php
    • app/Http/Controllers/ServerController.php
View full example

spatie/spatie.be

  • 493
  • Created Oct 2020
  • Updated Nov 2025

Files in this example

  • app/Models/Ad.php
    • app/Jobs/RandomizeAdsOnGitHubRepositoriesJob.php
View full example

saleem-hadad/finance

  • 404
  • Created Jan 2022
  • Updated Nov 2025

Files in this example

  • app/Models/Transaction.php
    • app/GraphQL/Queries/TotalExpensesTrend.php
View full example

LaravelDaily/Laravel-Support-Ticketing

  • 294
  • Created Nov 2019
  • Updated Mar 2023

Files in this example

  • app/Ticket.php
    • app/Http/Controllers/Admin/TicketsController.php
View full example

christophrumpel/larastreamers

  • 238
  • Created May 2021
  • Updated Oct 2025

Files in this example

  • app/Models/Stream.php
    • app/Http/Controllers/PageHomeController.php
View full example

PHPJunior/mtube

  • 144
  • Created Jul 2021
  • Updated Mar 2023

Files in this example

  • app/Models/Channel/Comment.php
    • app/Http/Livewire/Frontend/Components/Comment.php
View full example

benjamincrozat/blog-v5

  • 126
  • Created Feb 2025
  • Updated Nov 2025

Files in this example

  • app/Models/Link.php
    • app/Http/Controllers/Links/ListLinksController.php
View full example

alkrauss48/simple-slides

  • 98
  • Created Nov 2023
  • Updated Oct 2025

Files in this example

  • app/Models/DailyView.php
    • app/Filament/Widgets/ViewStats.php
View full example

crivion/laraboard-careers

  • 79
  • Created Jul 2022
  • Updated May 2023

Files in this example

  • app/Models/Job.php
    • app/Http/Controllers/Front/HomepageController.php
View full example

driesvints/driesvints.com

  • 74
  • Created May 2020
  • Updated Nov 2025

Files in this example

  • app/Models/Post.php
    • app/Http/Controllers/BlogController.php
View full example

nabilhassen/larasense

  • 62
  • Created Nov 2024
  • Updated Oct 2025

Files in this example

  • app/Models/Publisher.php
    • app/Console/Commands/LarasenseBotCommand.php
View full example

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.