Last active
May 5, 2018 20:18
-
-
Save joaorobertopb/a28f51a334f21502719493dc1b2179ba to your computer and use it in GitHub Desktop.
Exemplo de código utilizado em um dos meus artigos: medium.com/@joaorobertopb
This file contains hidden or 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 | |
//Trecho de código, retirado de https://github.com/laravel/framework/blob/5.6/src/Illuminate/Database/Eloquent/Model.php#L189 | |
/** | |
* The "booting" method of the model. | |
* | |
* @return void | |
*/ | |
protected static function boot() | |
{ | |
static::bootTraits(); | |
} | |
/** | |
* Boot all of the bootable traits on the model. | |
* | |
* @return void | |
*/ | |
protected static function bootTraits() | |
{ | |
$class = static::class; | |
foreach (class_uses_recursive($class) as $trait) { | |
if (method_exists($class, $method = 'boot'.class_basename($trait))) { | |
forward_static_call([$class, $method]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment