-
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
8 changed files
with
218 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\PersonelJabatanCategory; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
class JabatanController extends Controller | ||
{ | ||
public function store(Request $request) | ||
{ | ||
$request->validate([ | ||
'category' => 'required', | ||
'jabatan' => 'required' | ||
]); | ||
DB::beginTransaction(); | ||
if (is_array($request->jabatan)) { | ||
foreach ($request->jabatan as $jabatan) { | ||
$personelJabatanCategory = new PersonelJabatanCategory(); | ||
$personelJabatanCategory->category = $request->category; | ||
$personelJabatanCategory->jabatan = $jabatan; | ||
$personelJabatanCategory->save(); | ||
} | ||
} else { | ||
$personelJabatanCategory = new PersonelJabatanCategory(); | ||
$personelJabatanCategory->category = $request->category; | ||
$personelJabatanCategory->jabatan = $request->jabatan; | ||
$personelJabatanCategory->save(); | ||
} | ||
DB::commit(); | ||
return redirect()->back()->with('success', 'Data berhasil disimpan'); | ||
} | ||
|
||
public function destroy($id) | ||
{ | ||
$personelJabatanCategory = PersonelJabatanCategory::find($id); | ||
if(!$personelJabatanCategory) { | ||
return redirect()->back()->with('error', 'Data tidak ditemukan'); | ||
} | ||
$personelJabatanCategory->delete(); | ||
return redirect()->back()->with('success', 'Data berhasil dihapus'); | ||
} | ||
} |
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,13 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class PersonelJabatanCategory extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected $fillable = ["category", "jabatan"]; | ||
} |
29 changes: 29 additions & 0 deletions
29
database/migrations/2024_11_23_173857_create_personel_jabatan_categories_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('personel_jabatan_categories', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string("category"); | ||
$table->string("jabatan")->unique(); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('personel_jabatan_categories'); | ||
} | ||
}; |
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,2 @@ | ||
- [ ] reset konsep + tambah validasi only showable in browser | ||
- [ ] cek ulang koordinat |
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