Skip to content

Instantly share code, notes, and snippets.

@AhmedHelalAhmed
Created March 13, 2020 19:15
Show Gist options
  • Save AhmedHelalAhmed/fa770c693b7520b1830b7efebb506726 to your computer and use it in GitHub Desktop.
Save AhmedHelalAhmed/fa770c693b7520b1830b7efebb506726 to your computer and use it in GitHub Desktop.
example for helpers
if (!function_exists('user')) {
/**
* Get the authenticated user.
*
* @return \App\Models\Auth\User
*/
function user()
{
// Get user from api/web
if (request()->is('api/*')) {
$user = app('Dingo\Api\Auth\Auth')->user();
} else {
$user = auth()->user();
}
return $user;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment