Examples of Observers (12)

Short information about observers

Observer class may be called as a type of Listener class, listening to the events of changes on particular Eloquent Model.
With the command php artisan make:observer --model=ModelName you can create an Observer class that would automatically listen to ModelName (like, "User") events like created(), updated(), etc.
A typical example is updating related records in other DB tables after some change happened in the main related table.
Read more in the official Laravel docs.

Repository: koel/koel (Github)
★ 12683 Created: Dec 2015 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Observers/SongObserver.php
- app/Providers/EventServiceProvider.php
Repository: akaunting/akaunting (Github)
★ 4174 Created: Sep 2017 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Observers/Transaction.php
- app/Providers/Observer.php
- config/app.php
Repository: pixelfed/pixelfed (Github)
★ 2997 Created: Apr 2018 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Observers/AvatarObserver.php
- app/Providers/AppServiceProvider.php
Repository: pterodactyl/panel (Github)
★ 2612 Created: Dec 2016 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Observers/ServerObserver.php
- app/Providers/AppServiceProvider.php
Repository: Bottelet/DaybydayCRM (Github)
★ 1748 Created: Jul 2016 Updated: Jun 2021 Laravel version: 7
Files in the example:
- app/Observers/TaskObserver.php
- app/Providers/AppServiceProvider.php
Repository: LaravelDaily/Laravel-Support-Ticketing (Github)
★ 152 Created: Nov 2019 Updated: Mar 2021 Laravel version: 8
Files in the example:
- app/Observers/TicketActionObserver.php
- app/Ticket.php
Repository: Astrotomic/opendor.me (Github)
★ 46 Created: May 2021 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Observers/OrganizationObserver.php
- app/Providers/EventServiceProvider.php
Repository: PHPJunior/mtube (Github)
★ 41 Created: Jul 2021 Updated: Aug 2021 Laravel version: 8
Files in the example:
- app/Observers/VideoObserver.php
- app/Providers/AppServiceProvider.php
Repository: ammannbe/RecipeManager (Github)
★ 19 Created: Dec 2018 Updated: Feb 2021 Laravel version: 8
Files in the example:
- app/Observers/Users/AuthorObserver.php
- app/Providers/ObserverServiceProvider.php
- config/app.php
Repository: devhub-az/devhub (Github)
★ 18 Created: Dec 2019 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Observers/ArticleObserver.php
- app/Providers/AppServiceProvider.php
Repository: Senither/ShareX-Media-Server (Github)
★ 9 Created: Oct 2016 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Observers/ImageObserver.php
- app/Providers/AppServiceProvider.php
Repository: Melcus/parking-system (Github)
★ 1 Created: May 2021 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Observers/ReservationObserver.php
- app/Providers/AppServiceProvider.php

Additional resources on observers: