Created
April 11, 2024 04:45
-
-
Save spout/7ff38c6915d59392fc1d2e638c0e2bb3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Providers; | |
use Illuminate\Support\ServiceProvider; | |
class ObserverServiceProvider extends ServiceProvider | |
{ | |
/** | |
* Bootstrap any application services. | |
* | |
* @return void | |
*/ | |
public function boot() | |
{ | |
foreach (glob(app_path() . '/Observers/*.php') as $filename) { | |
$filename = pathinfo($filename, PATHINFO_FILENAME); | |
$observerClass = 'App\\Observers\\' . $filename; | |
$modelClass = 'App\\Models\\' . str_replace('Observer', '', $filename); | |
$modelClass::observe($observerClass); | |
} | |
} | |
/** | |
* Register the service provider. | |
* | |
* @return void | |
*/ | |
public function register() | |
{ | |
// | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment