'Database\\Factories\\'.class_basename($model).'Factory' ); // Navigation is built from config only once there is a schema to talk // to; during a fresh install the tables do not exist yet. if (InstallationState::isDbCreated()) { $this->addMenus(); } $this->bootBroadcast(); // The public demo build must never put real mail on the wire. if (config('app.env') === 'demo') { Mail::fake(); Notification::fake(); } } /** * Register container bindings. */ public function register(): void { BouncerModels::scope(new BouncerDefaultScope); } /** * Publish every navigation tree the SPA can ask for. * * Keys are the registered menu names; values are the config entries each * one is built from. Note the customer portal menu is registered under a * name that differs from its config key. */ public function addMenus() { $sources = [ 'main_menu' => 'invoiceshelf.main_menu', 'admin_menu' => 'invoiceshelf.admin_menu', 'setting_menu' => 'invoiceshelf.setting_menu', 'customer_portal_menu' => 'invoiceshelf.customer_menu', ]; foreach ($sources as $name => $configKey) { \Menu::make($name, function ($menu) use ($configKey) { foreach (config($configKey) as $data) { $this->generateMenu($menu, $data); } }); } } /** * Append one configured entry to a menu under construction. * * Everything past the title and link rides along as item metadata, which * is what the bootstrap endpoints filter and hand to the frontend. */ public function generateMenu($menu, $data) { $item = $menu->add($data['title'], $data['link']); $meta = [ 'icon' => $data['icon'], 'name' => $data['name'], 'owner_only' => $data['owner_only'], 'super_admin_only' => $data['super_admin_only'] ?? false, 'ability' => $data['ability'], 'model' => $data['model'], 'group' => $data['group'], 'group_label' => $data['group_label'] ?? '', 'priority' => $data['priority'] ?? 100, ]; foreach ($meta as $key => $value) { $item->data($key, $value); } } /** * Expose the broadcasting auth endpoint behind the API guard. */ public function bootBroadcast() { Broadcast::routes(['middleware' => 'api.auth']); } }