-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: handle errors in production (#801)
- Loading branch information
Showing
9 changed files
with
223 additions
and
95 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
namespace App\Http\Middleware; | ||
|
||
use Inertia\Middleware; | ||
use Illuminate\Http\Request; | ||
use App\Helpers\InstanceHelper; | ||
|
||
class HandleInertiaRequests extends Middleware | ||
{ | ||
/** | ||
* The root template that's loaded on the first page visit. | ||
* | ||
* @see https://inertiajs.com/server-side-setup#root-template | ||
* @var string | ||
*/ | ||
protected $rootView = 'app'; | ||
|
||
/** | ||
* Determines the current asset version. | ||
* | ||
* @see https://inertiajs.com/asset-versioning | ||
* @param \Illuminate\Http\Request $request | ||
* @return string|null | ||
*/ | ||
public function version(Request $request) | ||
{ | ||
return parent::version($request); | ||
} | ||
|
||
/** | ||
* Defines the props that are shared by default. | ||
* | ||
* @see https://inertiajs.com/shared-data | ||
* @param \Illuminate\Http\Request $request | ||
* @return array | ||
*/ | ||
public function share(Request $request) | ||
{ | ||
return array_merge(parent::share($request), [ | ||
'auth' => fn () => [ | ||
'user' => $request->user() ? [ | ||
'id' => $request->user()->id, | ||
'first_name' => $request->user()->first_name, | ||
'last_name' => $request->user()->last_name, | ||
'email' => $request->user()->email, | ||
'name' => $request->user()->name, | ||
'show_help' => $request->user()->show_help, | ||
] : null, | ||
'company' => $request->user() && ! is_null(InstanceHelper::getLoggedCompany()) ? InstanceHelper::getLoggedCompany() : null, | ||
'employee' => $request->user() && ! is_null(InstanceHelper::getLoggedEmployee()) ? [ | ||
'id' => InstanceHelper::getLoggedEmployee()->id, | ||
'first_name' => InstanceHelper::getLoggedEmployee()->first_name, | ||
'last_name' => InstanceHelper::getLoggedEmployee()->last_name, | ||
'name' => InstanceHelper::getLoggedEmployee()->name, | ||
'permission_level' => InstanceHelper::getLoggedEmployee()->permission_level, | ||
'display_welcome_message' => InstanceHelper::getLoggedEmployee()->display_welcome_message, | ||
'user' => (! InstanceHelper::getLoggedEmployee()->user) ? null : [ | ||
'id' => InstanceHelper::getLoggedEmployee()->user_id, | ||
], | ||
] : null, | ||
], | ||
'help_links' => fn () => config('officelife.help_links'), | ||
'flash' => [ | ||
'message' => fn () => $request->session()->get('message'), | ||
'success' => fn () => $request->session()->get('success'), | ||
], | ||
'errors' => fn () => $request->session()->get('errors') | ||
? $request->session()->get('errors')->getBag('default')->getMessages() | ||
: [], | ||
]); | ||
} | ||
} |
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
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
Oops, something went wrong.