From 1d3fac965dba9b901bf2b182b4336e5e4bdd4540 Mon Sep 17 00:00:00 2001 From: Felipe Date: Mon, 23 Oct 2023 10:29:15 -0500 Subject: [PATCH] notificaciones migracion y maquetado y modelo --- app/Http/Livewire/Bell.php | 16 ++++++ app/Models/Notificacion.php | 33 ++++++++++++ ...3_10_17_145853_create_pendientes_table.php | 6 +-- ..._23_101443_create_notificaciones_table.php | 50 +++++++++++++++++++ .../views/layouts/navigationup.blade.php | 7 +++ resources/views/livewire/bell.blade.php | 20 ++++++++ 6 files changed, 129 insertions(+), 3 deletions(-) create mode 100644 app/Http/Livewire/Bell.php create mode 100644 app/Models/Notificacion.php create mode 100644 database/migrations/2023_10_23_101443_create_notificaciones_table.php create mode 100644 resources/views/livewire/bell.blade.php diff --git a/app/Http/Livewire/Bell.php b/app/Http/Livewire/Bell.php new file mode 100644 index 0000000..3c54134 --- /dev/null +++ b/app/Http/Livewire/Bell.php @@ -0,0 +1,16 @@ +belongsTo(User::class, 'remitente_id'); + } + + public function destinatario() + { + return $this->belongsTo(User::class, 'destinatario_id'); + } +} + diff --git a/database/migrations/2023_10_17_145853_create_pendientes_table.php b/database/migrations/2023_10_17_145853_create_pendientes_table.php index 109bfaa..5a29939 100644 --- a/database/migrations/2023_10_17_145853_create_pendientes_table.php +++ b/database/migrations/2023_10_17_145853_create_pendientes_table.php @@ -15,12 +15,12 @@ return new class extends Migration { Schema::create('pendientes', function (Blueprint $table) { $table->id(); - $table->unsignedBigInteger('historial_id')->nullable();; - $table->unsignedBigInteger('servicio_id')->nullable();; + $table->unsignedBigInteger('historial_id')->nullable(); + $table->unsignedBigInteger('servicio_id')->nullable(); $table->string('cantidad')->nullable(); $table->string('estado')->nullable(); $table->foreign('historial_id')->references('id')->on('historiales')->onDelete('cascade'); - $table->foreign('servicio_id')->references('id')->on('servicios')->onUpdate('cascade');; + $table->foreign('servicio_id')->references('id')->on('servicios')->onUpdate('cascade'); $table->timestamps(); }); } diff --git a/database/migrations/2023_10_23_101443_create_notificaciones_table.php b/database/migrations/2023_10_23_101443_create_notificaciones_table.php new file mode 100644 index 0000000..1768efe --- /dev/null +++ b/database/migrations/2023_10_23_101443_create_notificaciones_table.php @@ -0,0 +1,50 @@ +id(); + $table->unsignedBigInteger('remitente_id')->nullable(); + $table->unsignedBigInteger('destinatario_id')->nullable(); + $table->string('titulo')->nullable(); + $table->text('descripcion')->nullable(); + $table->boolean('estado')->default(true); + $table->boolean('todos')->default(false); + + $table->foreign('remitente_id') + ->references('id') + ->on('users') + ->onDelete('cascade') + ->onUpdate('cascade'); + + $table->foreign('destinatario_id') + ->references('id') + ->on('users') + ->onDelete('cascade') + ->onUpdate('cascade'); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('notificaciones'); + } +}; diff --git a/resources/views/layouts/navigationup.blade.php b/resources/views/layouts/navigationup.blade.php index f12a15b..fc9421f 100644 --- a/resources/views/layouts/navigationup.blade.php +++ b/resources/views/layouts/navigationup.blade.php @@ -20,7 +20,14 @@ + +
+ + {{-- @livewire('bell') --}} + + + @if ( auth()->user()->rol->nombre != "editor")
$ {{number_format(Auth::user()->saldo->valor) ?? '0'}}
diff --git a/resources/views/livewire/bell.blade.php b/resources/views/livewire/bell.blade.php new file mode 100644 index 0000000..0febcf5 --- /dev/null +++ b/resources/views/livewire/bell.blade.php @@ -0,0 +1,20 @@ +
+
+ + {{ $noti > 9 ? '9+' : $noti }} + + + + +
+ +
+
+ hola hola + hola +
+
+