From 1275a7450632b75390a676bc985c780712ee8089 Mon Sep 17 00:00:00 2001 From: kusowl Date: Tue, 13 Jan 2026 18:06:27 +0530 Subject: [PATCH] feat: broker profile - add morph to relationship - add profile markup - modify page-heading.blade.php to accept center and end sections --- .../Broker/BrokerProfileController.php | 45 ++++++++++++++ app/Http/Controllers/BrokerDealController.php | 8 --- app/Models/Broker.php | 22 +++++++ app/Models/User.php | 10 +++ ...2026_01_13_103047_create_brokers_table.php | 32 ++++++++++ ...13_105915_add_morph_relationiship_role.php | 28 +++++++++ .../components/dashboard/navbar.blade.php | 2 +- .../dashboard/page-heading.blade.php | 38 ++++++++---- .../views/components/ui/button-sm.blade.php | 2 +- .../views/components/ui/button.blade.php | 2 +- .../dashboards/broker/profile/show.blade.php | 61 +++++++++++++++++++ routes/web.php | 5 +- 12 files changed, 230 insertions(+), 25 deletions(-) create mode 100644 app/Http/Controllers/Broker/BrokerProfileController.php create mode 100644 app/Models/Broker.php create mode 100644 database/migrations/2026_01_13_103047_create_brokers_table.php create mode 100644 database/migrations/2026_01_13_105915_add_morph_relationiship_role.php create mode 100644 resources/views/dashboards/broker/profile/show.blade.php diff --git a/app/Http/Controllers/Broker/BrokerProfileController.php b/app/Http/Controllers/Broker/BrokerProfileController.php new file mode 100644 index 0000000..b01dec1 --- /dev/null +++ b/app/Http/Controllers/Broker/BrokerProfileController.php @@ -0,0 +1,45 @@ +with('name', $profile->name) + ->with('joinDate', $profile->created_at->format('F Y')) + ->with('email', $profile->email); + } + + /** + * Show the form for editing the specified resource. + */ + public function edit(string $id) + { + // + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, string $id) + { + // + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(string $id) + { + // + } +} diff --git a/app/Http/Controllers/BrokerDealController.php b/app/Http/Controllers/BrokerDealController.php index 867a5e7..73ff771 100644 --- a/app/Http/Controllers/BrokerDealController.php +++ b/app/Http/Controllers/BrokerDealController.php @@ -52,14 +52,6 @@ public function store(StoreBrokerDeal $request, FileService $fileService) return to_route('broker.dashboard')->with('success', 'Deal has been created.'); } - /** - * Display the specified resource. - */ - public function show(string $id) - { - // - } - /** * Show the form for editing the specified resource. */ diff --git a/app/Models/Broker.php b/app/Models/Broker.php new file mode 100644 index 0000000..06e0055 --- /dev/null +++ b/app/Models/Broker.php @@ -0,0 +1,22 @@ + 'boolean', + 'active' => 'boolean', + ]; + } + + public function user(): MorphOne + { + return $this->morphOne(User::class, 'type'); + } +} diff --git a/app/Models/User.php b/app/Models/User.php index cb10c1c..bde7e60 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -5,7 +5,9 @@ // use Illuminate\Contracts\Auth\MustVerifyEmail; use App\Enums\UserTypes; use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\MorphTo; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; @@ -59,4 +61,12 @@ public function deals(): HasMany { return $this->hasMany(Deal::class); } + + /** + * Returns model of User's type + */ + public function type(): MorphTo + { + return $this->morphTo(); + } } diff --git a/database/migrations/2026_01_13_103047_create_brokers_table.php b/database/migrations/2026_01_13_103047_create_brokers_table.php new file mode 100644 index 0000000..5d9502c --- /dev/null +++ b/database/migrations/2026_01_13_103047_create_brokers_table.php @@ -0,0 +1,32 @@ +id(); + $table->text('bio'); + $table->string('location'); + $table->string('phone')->nullable(); + $table->boolean('verified')->default(false); + $table->boolean('active')->default(true); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('brokers'); + } +}; diff --git a/database/migrations/2026_01_13_105915_add_morph_relationiship_role.php b/database/migrations/2026_01_13_105915_add_morph_relationiship_role.php new file mode 100644 index 0000000..d91cf1e --- /dev/null +++ b/database/migrations/2026_01_13_105915_add_morph_relationiship_role.php @@ -0,0 +1,28 @@ +nullableMorphs('type'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->dropMorphs('type'); + }); + } +}; diff --git a/resources/views/components/dashboard/navbar.blade.php b/resources/views/components/dashboard/navbar.blade.php index 8b6b78c..4cb03bb 100644 --- a/resources/views/components/dashboard/navbar.blade.php +++ b/resources/views/components/dashboard/navbar.blade.php @@ -10,7 +10,7 @@