Created
November 27, 2021 04:24
-
-
Save alfelric/b41b9e695e02f834b9c81ac04b653efb to your computer and use it in GitHub Desktop.
Get User Detail Attribute
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 | |
use Illuminate\Support\Facades\Http; | |
class User extends Model | |
{ | |
protected $appends = ['user_detail']; | |
public function getUserDetailAttribute() | |
{ | |
$userId = $this->user_id; | |
$endpoint = "http://localhost:8002/api/user/$userId"; | |
$response = Http::acceptJson()->get($endpoint); | |
return $response->json(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment