Skip to content

1. Fix/status notes field #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
DB_PORT=5432
DB_DATABASE=recompose
DB_USERNAME=recompose
DB_PASSWORD=secret

BROADCAST_DRIVER=log
CACHE_DRIVER=file
Expand Down
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/.phpunit.cache
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.env.production
.phpunit.result.cachecp
Homestead.json
Homestead.yaml
auth.json
npm-debug.log
yarn-error.log
/.fleet
/.idea
/.vscode
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $ git clone https://github.com/aspsptyd/recompose-job.git

Step 2: Open Project dengan VScode kemudian copy file `.env.example` dan rename file menjadi `.env`

Step 3: Buat Database di Local Database Server dengan nama `db_recomposejob`
Step 3: Buat Database di Local Database Server dengan nama `db_recomposejob`. Jika sudah menginstall `docker-compose` maka cukup menjalankan perintah `docker-compose up -d` dan langsung ke step 5.

Step 4: Setup Nama Database pada file .env

Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

namespace App\Http\Controllers;

use App\Lib\ReminderStatus;
use App\Models\Reminder as ModelReminder;
use Illuminate\Http\Request;

class DashboardController extends Controller
{
public function index()
{
$countReminder = ModelReminder::where('status_notes', 1)->count();
$countReminder = ModelReminder::where('status_notes', ReminderStatus::OPEN)->count();

$data = [
'reminderCount' => $countReminder,
Expand Down
29 changes: 16 additions & 13 deletions app/Http/Controllers/ReminderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers;

use App\Models\Reminder as ModelReminder;
use App\Lib\ReminderStatus;
use Illuminate\Http\Request;

class ReminderController extends Controller
Expand All @@ -26,18 +27,20 @@ public function index()

public function create()
{
return view('reminder.form');
return view('reminder.form', [
'status_cases' => ReminderStatus::cases(),
]);
}

public function store(Request $request)
{
$data = [
'reminder_title' =>$request->reminder_title,
'reminder_detail' =>$request->reminder_detail,
'created_by' =>$request->created_by,
'project_name' =>$request->project_name,
'status_notes' =>$request->status_notes,
];
$data = $request->only([
'reminder_title',
'reminder_detail',
'created_by',
'project_name',
'status_notes',
]);

ModelReminder::create($data);

Expand All @@ -52,7 +55,7 @@ public function show()
public function edit($id)
{
$reminder = ModelReminder::find($id);
return view('reminder.form', ['reminder' => $reminder]);
return view('reminder.form', ['reminder' => $reminder]);
}

public function update(Request $request, $id)
Expand Down Expand Up @@ -82,21 +85,21 @@ public function delete($id)
return redirect()->route('reminder.index');
}

public function close($id)
public function close($id)
{
$data = [
'status_notes' => 0,
'status_notes' => ReminderStatus::CLOSE,
];

ModelReminder::find($id)->update($data);

return redirect()->route('reminder.index');
}

public function open($id)
public function open($id)
{
$data = [
'status_notes' => 1,
'status_notes' => ReminderStatus::OPEN,
];

ModelReminder::find($id)->update($data);
Expand Down
8 changes: 8 additions & 0 deletions app/Lib/ReminderStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace App\Lib;

enum ReminderStatus: string {
case OPEN = "open";
case CLOSE = "close";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Lib\ReminderStatus;

return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('reminder', function (Blueprint $table) {
$table->dropColumn('status_notes');
});
Schema::table('reminder', function (Blueprint $table) {
$table->string('status_notes')->default(ReminderStatus::OPEN->value);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('reminder', function (Blueprint $table) {
$table->dropColumn('status_notes');
});
Schema::table('reminder', function (Blueprint $table) {
$table->integer('status_notes')->nullable();
});
}
};
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: "3.5"
services:
postgres:
image: postgres:14
environment:
- POSTGRES_USER=recompose
- POSTGRES_PASSWORD=secret
- POSTGRES_DB=recompose
- PGDATA=/var/lib/postgresql/data
networks:
- testing_network
volumes:
- pgsqldata:/var/lib/postgresql/data
ports:
- 5432:5432

networks:
testing_network:

volumes:
pgsqldata:
Loading