diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php new file mode 100644 index 0000000..f329280 --- /dev/null +++ b/app/Http/Controllers/CategoryController.php @@ -0,0 +1,75 @@ + Category::paginate(), + ]); + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + $request->validate([ + 'name' => 'required|string|max:255', + 'short' => 'required|string|max:255', + 'duration' => 'required|numeric' + ]); + + Category::create([ + 'name' => $request->name, + 'short' => $request->short, + 'duration' => $request->duration, + ]); + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\Response + */ + public function update(Request $request, Category $category) + { + $request->validate([ + 'name' => 'required|string|max:255', + 'short' => 'required|string|max:255', + 'duration' => 'required|numeric' + ]); + + $category->update([ + 'name' => $request->name, + 'short' => $request->short, + 'duration' => $request->duration, + ]); + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy(Category $category) + { + $category->delete(); + } +} diff --git a/app/Http/Controllers/GeneralController.php b/app/Http/Controllers/GeneralController.php index 05d36b8..084cc9b 100644 --- a/app/Http/Controllers/GeneralController.php +++ b/app/Http/Controllers/GeneralController.php @@ -11,10 +11,10 @@ class GeneralController extends Controller public function index() { return inertia('Dashboard', [ - 'count_active' => Document::where('status', Document::ACTIVE)->count(), - 'count_update' => Document::where('status', Document::UPDATE)->count(), - 'count_expired' => Document::where('status', Document::EXPIRED)->count(), - 'count_total' => Document::count(), + 'count_active' => 0, + 'count_update' => 0, + 'count_expired' => 0, + 'count_total' => 0, 'events' => DocumentReminder::with('document.type')->get(), ]); } diff --git a/app/Http/Controllers/TypeController.php b/app/Http/Controllers/TypeController.php new file mode 100644 index 0000000..7f4478d --- /dev/null +++ b/app/Http/Controllers/TypeController.php @@ -0,0 +1,63 @@ + Type::paginate(), + ]); + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + $request->validate([ + 'name' => 'required|string|max:255' + ]); + + Type::create(['name' => $request->name]); + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\Response + */ + public function update(Request $request, Type $type) + { + $request->validate([ + 'name' => 'required|string|max:255' + ]); + + $type->update(['name' => $request->name]); + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy(Type $type) + { + $type->delete(); + } +} diff --git a/app/Models/Category.php b/app/Models/Category.php new file mode 100644 index 0000000..7c4f461 --- /dev/null +++ b/app/Models/Category.php @@ -0,0 +1,17 @@ + 'datetime:Y-m-d', - 'end_date' => 'datetime:Y-m-d' + 'publish_date' => 'datetime:Y-m-d', + 'due_date' => 'datetime:Y-m-d' ]; - public const ACTIVE = 0; - public const UPDATE = 1; - public const EXPIRED = 2; - - public function department() - { - return $this->belongsTo(Department::class, 'department_id'); - } - - public function type() - { - return $this->belongsTo(TypeDoc::class, 'type_doc_id'); - } - - public function reminders() - { - return $this->hasMany(DocumentReminder::class); - } - - public function shares() - { - return $this->hasMany(DocumentShare::class); - } - public function creator() { return $this->belongsTo(User::class, 'user_id'); diff --git a/app/Models/Type.php b/app/Models/Type.php new file mode 100644 index 0000000..4b9b69b --- /dev/null +++ b/app/Models/Type.php @@ -0,0 +1,15 @@ +id(); - $table->integer('no', false); - $table->string('name'); - $table->string('no_doc'); - $table->foreignId('type_doc_id')->constrained(); - $table->string('company_name'); - $table->string('first_person_name'); - $table->string('second_person_name'); - $table->dateTime('start_date'); - $table->dateTime('end_date'); - $table->foreignId('department_id')->constrained(); - $table->string('pic_name'); - $table->string('email'); - $table->text('note'); - $table->string('document'); - $table->foreignId('user_id')->constrained(); - $table->smallInteger('status')->default(0); + $table->string("no")->nullable(); + $table->string("no_doc")->nullable(); + $table->string("name")->nullable(); + $table->string("company_name")->nullable(); + $table->foreignId("type_id")->constrained(); //select jenis + $table->foreignId("category_id")->constrained(); //select + $table->string("publisher")->nullable(); + $table->text("description")->nullable(); + $table->timestamp("publish_date")->nullable(); + $table->timestamp("due_date")->nullable(); //for reminder + $table->smallInteger("status")->default(1); //only 1 yes/ 0no + $table->smallInteger("type")->default(1); //only 1 tetap/ 0tidak tetap + $table->string("group")->nullable(); + $table->string("region")->nullable(); + $table->string("document")->nullable(); + $table->foreignId("user_id")->constrained(); $table->timestamps(); }); } diff --git a/database/migrations/2023_01_26_015830_create_types_table.php b/database/migrations/2023_01_26_015830_create_types_table.php new file mode 100644 index 0000000..0d469f0 --- /dev/null +++ b/database/migrations/2023_01_26_015830_create_types_table.php @@ -0,0 +1,32 @@ +id(); + $table->string('name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('types'); + } +}; diff --git a/database/migrations/2023_01_26_015838_create_categories_table.php b/database/migrations/2023_01_26_015838_create_categories_table.php new file mode 100644 index 0000000..6e0e8f2 --- /dev/null +++ b/database/migrations/2023_01_26_015838_create_categories_table.php @@ -0,0 +1,34 @@ +id(); + $table->string("name"); + $table->string("short"); + $table->integer("duration"); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('categories'); + } +}; diff --git a/resources/js/Layouts/AuthenticatedLayout.jsx b/resources/js/Layouts/AuthenticatedLayout.jsx index 27b7672..f2dca7c 100644 --- a/resources/js/Layouts/AuthenticatedLayout.jsx +++ b/resources/js/Layouts/AuthenticatedLayout.jsx @@ -10,8 +10,8 @@ const rs = [ {name: "Dashboard", route: "dashboard", show: true}, {name: "Dokumen", show: true, items: [ {name: "Dokumen", route: 'docs.index', show: true, permission: 'view-document'}, - {name: "Ketegori", route: 'docs.index', show: true, permission: 'view-category'}, - {name: "Jenis", route: 'docs.index', show: true, permission: 'view-type'}, + {name: "Ketegori", route: 'categories.index', show: true, permission: 'view-category'}, + {name: "Jenis", route: 'types.index', show: true, permission: 'view-type'}, ]}, {name: "User", show: true, items: [ {name:"User", route: "users.index", show: true, permission: 'view-user'}, @@ -51,7 +51,7 @@ export default function Authenticated({ auth, children, flash, notify }) { Monitor Doc
Id | +Nama | +Singkatan | +Durasi | ++ |
---|---|---|---|---|
{category.id} | +{category.name} | +{category.short} | +{category.duration} | +
+ {canUpdate && (
+
+ toggle(category)
+ }
+ >
+ Edit
+
+ )}
+ {canDelete && (
+
+ handleDelete(category)
+ }
+ >
+ Delete
+
+ )}
+ |
+
Id | +Nama | ++ |
---|---|---|
{type.id} | +{type.name} | +
+ {canUpdate && (
+
+ toggle(type)
+ }
+ >
+ Edit
+
+ )}
+ {canDelete && (
+
+ handleDelete(type)
+ }
+ >
+ Delete
+
+ )}
+ |
+