Created
July 22, 2021 04:15
-
-
Save EricMcWinNer/4fd6193d5edbb2259eca147711b2d136 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\Models; | |
use Illuminate\Database\Eloquent\Model; | |
class User extends Model | |
{ | |
/** | |
* The booted method of the model | |
* | |
* Define all attributes here like normal code | |
* | |
* @param string $value | |
* @return string | |
*/ | |
protected static function booted() { | |
static::retrieved(function($user) { | |
$user->first_name = ucfirst($user->first_name); | |
$user->phone_number = $user->country_code . $user->phone; | |
return $user; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment