-
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.
Merge pull request #3 from JayJull/v2-task
V2 task
- Loading branch information
Showing
20 changed files
with
588 additions
and
117 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\Task; | ||
use App\Models\TaskNotification; | ||
use App\Models\User; | ||
use Illuminate\Http\Request; | ||
|
||
class TaskController extends Controller | ||
{ | ||
// | ||
public function index() | ||
{ | ||
$tasks = Task::all(); | ||
return view('personel.task.index', compact('tasks')); | ||
} | ||
|
||
public function detail($id) | ||
{ | ||
$task = Task::find($id); | ||
return view('personel.task.detail', compact('task')); | ||
} | ||
|
||
public function store(Request $request) | ||
{ | ||
$request->validate([ | ||
"berkas" => "file|mimes:pdf,jpg,jpeg,png", | ||
"deskripsi" => "required" | ||
]); | ||
|
||
if ($request->hasFile("berkas")) { | ||
$file = $request->file('berkas'); | ||
$fileName = time() . '_' . $file->getClientOriginalName(); | ||
$berkas = "/storage/" . $file->storeAs('files', $fileName, 'public'); | ||
} else { | ||
$request->validate([ | ||
"url" => "required" | ||
]); | ||
$berkas = $request->url; | ||
} | ||
|
||
$task = Task::create([ | ||
"deskripsi" => $request->deskripsi, | ||
"berkas" => $berkas, | ||
]); | ||
|
||
$users = User::all(); | ||
foreach ($users as $user){ | ||
TaskNotification::create([ | ||
"user_id" => $user->id, | ||
"task_id" => $task->id, | ||
]); | ||
} | ||
|
||
return redirect()->route("task"); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -12,5 +12,6 @@ class Konsep extends Model | |
"name", | ||
"berkas", | ||
"cabang_id", | ||
'task_id', | ||
]; | ||
} |
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\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Task extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected $fillable = [ | ||
'berkas', 'deskripsi' | ||
]; | ||
|
||
} |
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,26 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class TaskNotification extends Model | ||
{ | ||
use HasFactory; | ||
protected $fillable = [ | ||
'user_id', | ||
'task_id', | ||
'is_read' | ||
]; | ||
|
||
public function task() | ||
{ | ||
return $this->belongsTo(Task::class); | ||
} | ||
|
||
public function notread() | ||
{ | ||
return $this->where("is_read", false)->get(); | ||
} | ||
} |
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
29 changes: 29 additions & 0 deletions
29
database/migrations/2024_11_27_113506_create_tasks_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,29 @@ | ||
<?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('tasks', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('berkas'); | ||
$table->text('deskripsi'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('tasks'); | ||
} | ||
}; |
28 changes: 28 additions & 0 deletions
28
database/migrations/2024_11_27_114142_add_task_column_on_konseps.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,28 @@ | ||
<?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::table('konseps', function (Blueprint $table) { | ||
$table->foreignId('task_id')->nullable()->constrained(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::table('konseps', function (Blueprint $table) { | ||
$table->dropColumn('task_id'); | ||
}); | ||
} | ||
}; |
31 changes: 31 additions & 0 deletions
31
database/migrations/2024_11_27_125533_create_task_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,31 @@ | ||
<?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('task_notifications', function (Blueprint $table) { | ||
$table->id(); | ||
$table->foreignId('user_id')->constrained(); | ||
$table->foreignId('task_id')->constrained(); | ||
$table->boolean('is_read')->default(0); | ||
|
||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('task_notifications'); | ||
} | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,34 @@ | ||
<!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 Task</h1> | ||
<div class="text-xl font-semibold text-gray-800 px-4 py-2 bg-gray-100 flex gap-4"> | ||
<a href="/rotasi/notification">Notifikasi</a> | ||
<a href="/rotasi/notification/task" class="underline">Notifikasi Task</a> | ||
</div> | ||
<section class="flex flex-col gap-4 min-h-[50vh]"> | ||
@forelse ($notifications as $notification) | ||
<a href="/personel/task/{{ $notification->task->id }}" | ||
class="flex flex-col gap-2 p-4 bg-[#003285] text-white rounded-md"> | ||
<p>{{ $notification->task->deskripsi }}</p> | ||
<p class="text-sm opacity-50 self-end">{{ $notification->created_at->diffForHumans() }}</p> | ||
</a> | ||
@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
Oops, something went wrong.