-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
179 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\Notification; | ||
use Illuminate\Http\Request; | ||
|
||
class NotificationController extends Controller | ||
{ | ||
public function index() | ||
{ | ||
$notifications = auth()->user()->profile->cabang->notifications; | ||
Notification::where('to', auth()->user()->profile->cabang->id)->update(['is_read' => true]); | ||
return view('notification.index', compact('notifications')); | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Notification extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected $fillable = [ | ||
"is_read", | ||
"status", | ||
"to", | ||
"cabang_asal_id", | ||
"cabang_tujuan_id", | ||
"pengajuan_id", | ||
]; | ||
|
||
public function user() | ||
{ | ||
return $this->belongsTo(User::class); | ||
} | ||
|
||
public function pengajuan() | ||
{ | ||
return $this->belongsTo(Pengajuan::class); | ||
} | ||
|
||
public function notread() | ||
{ | ||
return $this->where("is_read", false)->get(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
database/migrations/2024_10_30_104942_create_notifications_table.php
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,33 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::create('notifications', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string("status"); | ||
$table->foreignId("to")->constrained("cabangs")->onDelete("cascade"); | ||
$table->boolean("is_read")->default(false); | ||
$table->foreignId("cabang_asal_id")->constrained("cabangs")->onDelete("cascade"); | ||
$table->foreignId("cabang_tujuan_id")->constrained("cabangs")->onDelete("cascade"); | ||
$table->foreignId("pengajuan_id")->constrained("pengajuans")->onDelete("cascade"); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('notifications'); | ||
} | ||
}; |
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,47 @@ | ||
<!DOCTYPE html> | ||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}"> | ||
|
||
<head> | ||
@include('components/head') | ||
<title>Air Mutasi | Profil</title> | ||
</head> | ||
|
||
<body class="font-sans tracking-wider"> | ||
@include('components/header', ['static' => true]) | ||
@include('components.modal-component') | ||
<main class="px-8 py-16"> | ||
<h1 class="text-3xl font-semibold mb-2">Notifikasi</h1> | ||
<section class="flex flex-col gap-4 min-h-[50vh]"> | ||
@forelse ($notifications as $notification) | ||
<div class="flex flex-col gap-2 p-4 bg-[#003285] text-white rounded-md"> | ||
<div class="flex flex-wrap gap-6"> | ||
<aside> | ||
<p>Status:</p> | ||
<strong>{{ $notification->status == 'dapat' ? 'Diterima' : ($notification->status == 'tidak' ? 'Tidak Diterima' : 'Disetujui') }}</strong> | ||
</aside> | ||
<aside> | ||
<p>Atas nama:</p> | ||
<strong>{{ $notification->pengajuan->nama_lengkap }}</strong> | ||
</aside> | ||
<aside> | ||
<p>Dari:</p> | ||
<strong>{{ $notification->pengajuan->lokasiAwal->nama }} | ||
({{ $notification->pengajuan->posisi_sekarang }})</strong> | ||
</aside> | ||
<aside> | ||
<p>Ke:</p> | ||
<strong>{{ $notification->pengajuan->lokasiTujuan->nama }} ({{ $notification->pengajuan->posisi_tujuan }})</strong> | ||
</aside> | ||
</div> | ||
<p class="text-sm opacity-50 self-end">{{ $notification->created_at->diffForHumans() }}</p> | ||
</div> | ||
@empty | ||
<p>Belum ada notifikasi</p> | ||
@endforelse | ||
</main> | ||
@include('components.footer') | ||
<script src="/script/nav.js"></script> | ||
<script src="/script/chatbot.js"></script> | ||
</body> | ||
|
||
</html> |
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