diff --git a/app/Http/Controllers/Dashboard/DatatableController.php b/app/Http/Controllers/Dashboard/DatatableController.php index 7b97653..65341a7 100644 --- a/app/Http/Controllers/Dashboard/DatatableController.php +++ b/app/Http/Controllers/Dashboard/DatatableController.php @@ -29,8 +29,6 @@ class DatatableController extends Controller public function classification(Request $request){ if ($request->ajax()) { - - $data = Classification::with(['subClassifications'])->get(); return DataTables::of($data) @@ -46,7 +44,7 @@ public function classification(Request $request){ $subClassificationCount = $data->subClassifications->count(); if($subClassificationCount > 0){ - return $subClassificationCount. ' [Lihat]'; + return $subClassificationCount. ' [Lihat]'; }else{ return $subClassificationCount; } diff --git a/app/Http/Controllers/Dashboard/SubClassificationController.php b/app/Http/Controllers/Dashboard/SubClassificationController.php index 7424434..7853a9b 100644 --- a/app/Http/Controllers/Dashboard/SubClassificationController.php +++ b/app/Http/Controllers/Dashboard/SubClassificationController.php @@ -30,8 +30,8 @@ public function create(Request $request){ ]; if($request->has('classification')){ - $classificationSlug = $request->query('classification'); - $viewData['classification'] = Classification::where('slug', '=', $classificationSlug)->first(); + $classificationId = $request->query('classification'); + $viewData['classification'] = Classification::where('id', '=', decrypt_id($classificationId))->first(); $viewData['fromClassification'] = true; }else{ $viewData['classifications'] = Classification::all(); diff --git a/app/Models/Classification.php b/app/Models/Classification.php index 5c32a56..8962990 100644 --- a/app/Models/Classification.php +++ b/app/Models/Classification.php @@ -3,14 +3,15 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\SoftDeletes; class Classification extends Model { + use SoftDeletes; protected $table = 'classifications'; protected $fillable = [ 'name', - 'slug', 'status', 'description', 'enhancer_id' diff --git a/app/Models/Legacy/OldClassification.php b/app/Models/Legacy/OldClassification.php new file mode 100644 index 0000000..1187ee7 --- /dev/null +++ b/app/Models/Legacy/OldClassification.php @@ -0,0 +1,15 @@ +id(); $table->string('name'); - $table->string('slug')->unique();; $table->text('description')->nullable(); $table->enum('status', ['0', '1'])->default('0'); $table->unsignedBigInteger('enhancer_id'); $table->foreign('enhancer_id')->references('id')->on('users'); $table->timestamps(); + $table->softDeletes(); }); } diff --git a/database/seeders/ClassificationSeeder.php b/database/seeders/ClassificationSeeder.php index 9e5dffc..a2b4ccb 100644 --- a/database/seeders/ClassificationSeeder.php +++ b/database/seeders/ClassificationSeeder.php @@ -3,8 +3,11 @@ namespace Database\Seeders; use App\Models\Classification; +use App\Models\Legacy\OldClassification; +use Carbon\Carbon; use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; +use Illuminate\Support\Str; class ClassificationSeeder extends Seeder { @@ -13,19 +16,19 @@ class ClassificationSeeder extends Seeder */ public function run(): void { - Classification::insert([ - [ - 'name' => 'Politik', - 'slug' => 'politik', + $legacyClassifications = OldClassification::withTrashed()->get(); + + foreach($legacyClassifications as $legacyClassification){ + Classification::create([ + 'id' => $legacyClassification->id, + 'name' => $legacyClassification->name, + 'status' => $legacyClassification->status, 'description' => null, - 'enhancer_id' => '1' - ], - [ - 'name' => 'Kiriminal', - 'slug' => 'kriminal', - 'description' => null, - 'enhancer_id' => '1' - ] - ]); + 'created_at' => $legacyClassification->created_at, + 'updated_at' => $legacyClassification->updated_at, + 'deleted_at' => $legacyClassification->deleted_at, + 'enhancer_id' => $legacyClassification->enhancer, + ]); + } } } diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 30d1909..1528dd6 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -15,10 +15,10 @@ public function run(): void { $this->call(RoleSeeder::class); $this->call(UserSeeder::class); + $this->call(ClassificationSeeder::class); $this->call(CompanySeeder::class); $this->call(MediaSeeder::class); $this->call(JournalistSeeder::class); - $this->call(ClassificationSeeder::class); $this->call(SubClassificationSeeder::class); $this->call(GovernmentAgencySeeder::class); } diff --git a/database/seeders/SubClassificationSeeder.php b/database/seeders/SubClassificationSeeder.php index 2f81c78..5d500a6 100644 --- a/database/seeders/SubClassificationSeeder.php +++ b/database/seeders/SubClassificationSeeder.php @@ -13,21 +13,6 @@ class SubClassificationSeeder extends Seeder */ public function run(): void { - SubClassification::insert([ - [ - 'name' => 'Pembacokan', - 'slug' => 'pembacokan', - 'description' => null, - 'classification_id' => '2', - 'enhancer_id' => '1' - ], - [ - 'name' => 'Tawuran', - 'slug' => 'tawuran', - 'description' => null, - 'classification_id' => '2', - 'enhancer_id' => '1' - ] - ]); + // } } diff --git a/resources/views/dashboard/classifications/show.blade.php b/resources/views/dashboard/classifications/show.blade.php index 9bc3c56..2331578 100644 --- a/resources/views/dashboard/classifications/show.blade.php +++ b/resources/views/dashboard/classifications/show.blade.php @@ -1,5 +1,5 @@ @include('partials.dashboard.head') -@include('partials.dashboard.sidebar', ['page' => 'classifications']) +@include('partials.dashboard.sidebar', ['page' => 'journalists']) @include('partials.dashboard.header')