app/Utilities/helpers.php
// We just create a list of functions that don't belong to any class// But, since they are global functions, it's important to check if their names don't exist somewhere else// Notice: you can create this file in any folder you want. In this case, they created it in app/Utilities if (!function_exists('user')) { function user() { if (request()->isApi()) { $user = app('Dingo\Api\Auth\Auth')->user(); } else { $user = auth()->user(); } return $user; }} if (!function_exists('company_date_format')) { function company_date_format() { $date_time = new class() { use DateTime; }; return $date_time->getCompanyDateFormat(); }} // ... other functions