diff --git a/app/Domains/Taxonomy/Models/Taxonomy.php b/app/Domains/Taxonomy/Models/Taxonomy.php
index dadd4cd1..450cf7c9 100644
--- a/app/Domains/Taxonomy/Models/Taxonomy.php
+++ b/app/Domains/Taxonomy/Models/Taxonomy.php
@@ -32,6 +32,17 @@ class Taxonomy extends Model
'properties',
];
+ public static $propertyType = [
+ 'string'=>'String',
+ 'integer' => 'Integer Number',
+ 'float' => 'Floating Point Number',
+ 'date' => 'Date',
+ 'datetime' => 'Date Time',
+ 'boolean' => 'Boolean',
+ 'url' => 'URL',
+ 'image' => 'Image'
+ ];
+
public function user()
{
return $this->belongsTo(User::class, 'created_by');
diff --git a/app/Domains/TaxonomyTerms/Models/TaxonomyTerms.php b/app/Domains/Taxonomy/Models/TaxonomyTerm.php
similarity index 71%
rename from app/Domains/TaxonomyTerms/Models/TaxonomyTerms.php
rename to app/Domains/Taxonomy/Models/TaxonomyTerm.php
index 7daa09da..6a8d8dc3 100644
--- a/app/Domains/TaxonomyTerms/Models/TaxonomyTerms.php
+++ b/app/Domains/Taxonomy/Models/TaxonomyTerm.php
@@ -1,21 +1,19 @@
model = $taxonomyTerms;
- }
-}
diff --git a/app/Http/Controllers/Backend/TaxonomyController.php b/app/Http/Controllers/Backend/TaxonomyController.php
index b8e97c5f..fbb47efa 100644
--- a/app/Http/Controllers/Backend/TaxonomyController.php
+++ b/app/Http/Controllers/Backend/TaxonomyController.php
@@ -4,6 +4,7 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
+use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\Controller;
use App\Domains\Taxonomy\Models\Taxonomy;
@@ -31,7 +32,22 @@ public function create()
*/
public function store(Request $request)
{
-
+ $validatedData =$request->validate([
+ 'code' => 'required|unique:taxonomies',
+ 'name' => 'required',
+ 'description' => 'nullable',
+ ]);
+
+ try{
+ $taxonomy = new Taxonomy($validatedData);
+ $taxonomy->properties = $request->properties;
+ $taxonomy->created_by = Auth::user()->id;
+ $taxonomy->save();
+ return redirect()->route('dashboard.taxonomy.index')->with('Success', 'Taxonomy created successfully');
+ }catch (\Exception $ex) {
+ Log::error('Failed to create taxonomy', ['error' => $ex->getMessage()]);
+ return abort(500);
+ }
}
/**
* Show the form for editing the specified resource.
@@ -41,13 +57,17 @@ public function store(Request $request)
*/
public function edit(Taxonomy $taxonomy)
{
- try{
- return view('backend.taxonomy.edit', ['taxonomy' => $taxonomy]);
- }catch (\Exception $ex) {
- Log::error('Failed to load taxonomy edit page', ['error' => $ex->getMessage()]);
+ try {
+ return view('backend.taxonomy.edit', [
+ 'taxonomy' => $taxonomy,
+ ]);
+ } catch (\Exception $ex) {
+ Log::error('Failed to load taxonomy edit page', ['error' => $ex->getMessage()]);
return abort(500);
}
}
+
+
/**
* Update the specified resource in storage.
*
@@ -57,6 +77,22 @@ public function edit(Taxonomy $taxonomy)
*/
public function update(Request $request, Taxonomy $taxonomy)
{
+ $data = $request->validate([
+ 'code' => 'required',
+ 'name' => 'required',
+ 'description' => 'nullable',
+ ]);
+
+ try{
+ $taxonomy->update($data);
+ $taxonomy->properties = $request->properties;
+ $taxonomy->updated_by = Auth::user()->id;
+ $taxonomy->save();
+ return redirect()->route('dashboard.taxonomy.index')->with('Success', 'Taxonomy updated successfully');
+ }catch (\Exception $ex) {
+ Log::error('Failed to update taxonomy', ['error' => $ex->getMessage()]);
+ return abort(500);
+ }
}
/**
diff --git a/app/Http/Controllers/Backend/TaxonomyTermsController.php b/app/Http/Controllers/Backend/TaxonomyTermController.php
similarity index 60%
rename from app/Http/Controllers/Backend/TaxonomyTermsController.php
rename to app/Http/Controllers/Backend/TaxonomyTermController.php
index 69e8886a..2e74610e 100644
--- a/app/Http/Controllers/Backend/TaxonomyTermsController.php
+++ b/app/Http/Controllers/Backend/TaxonomyTermController.php
@@ -5,9 +5,9 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use App\Http\Controllers\Controller;
-use App\Domains\TaxonomyTerms\Models\TaxonomyTerms;
+use App\Domains\Taxonomy\Models\TaxonomyTerm;
-class TaxonomyTermsController extends Controller
+class TaxonomyTermController extends Controller
{
/**
* Show the form for creating a new resource.
@@ -17,7 +17,7 @@ class TaxonomyTermsController extends Controller
public function create()
{
try{
- return view('backend.taxonomyTerms.create');
+ return view('backend.taxonomy.terms.create');
}catch (\Exception $ex) {
Log::error('Failed to load taxonomy terms creation page', ['error' => $ex->getMessage()]);
return abort(500);
@@ -36,15 +36,15 @@ public function store(Request $request)
/**
* Show the form for editing the specified resource.
*
- * @param \App\Domains\TaxonomyTerms\Models\TaxonomyTerms $taxonomyTerms
+ * @param \App\Domains\TaxonomyTerm\Models\TaxonomyTerm $taxonomyTerm
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
- public function edit(TaxonomyTerms $taxonomyTerms)
+ public function edit(TaxonomyTerm $taxonomyTerm)
{
try{
- return view('backend.taxonomyTerms.edit', ['taxonomyTerms' => $taxonomyTerms]);
+ return view('backend.taxonomy.terms.edit', ['taxonomyTerm' => $taxonomyTerm]);
}catch (\Exception $ex) {
- Log::error('Failed to load taxonomy terms edit page', ['error' => $ex->getMessage()]);
+ Log::error('Failed to load taxonomy term edit page', ['error' => $ex->getMessage()]);
return abort(500);
}
}
@@ -52,40 +52,39 @@ public function edit(TaxonomyTerms $taxonomyTerms)
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
- * @param \App\Domains\TaxonomyTerms\Models\TaxonomyTerms $taxonomyTerms
+ * @param \App\Domains\TaxonomyTerm\Models\TaxonomyTerm $taxonomyTerm
* @return \Illuminate\Http\RedirectResponse
*/
- public function update(Request $request, TaxonomyTerms $taxonomyTerms)
+ public function update(Request $request, TaxonomyTerm $taxonomyTerm)
{
}
/**
* Confirm to delete the specified resource from storage.
*
- * @param \App\Domains\TaxonomyTerms\Models\TaxonomyTerms $taxonomyTerms
+ * @param \App\Domains\TaxonomyTerm\Models\TaxonomyTerm $taxonomyTerm
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
- public function delete(TaxonomyTerms $taxonomyTerms)
+ public function delete(TaxonomyTerm $taxonomyTerm)
{
- return view('backend.taxonomyTerms.delete', compact('taxonomyTerms'));
+ return view('backend.taxonomy.terms.delete', compact('taxonomyTerm'));
}
/**
* Remove the specified resource from storage.
*
- * @param \App\Domains\TaxonomyTerms\Models\TaxonomyTerms $taxonomyTerms
+ * @param \App\Domains\TaxonomyTerm\Models\TaxonomyTerm $taxonomyTerm
* @return \Illuminate\Http\RedirectResponse|null
*/
- public function destroy(TaxonomyTerms $taxonomyTerms)
+ public function destroy(TaxonomyTerm $taxonomyTerm)
{
try {
- $taxonomyTerms->delete();
- return redirect()->route('dashboard.taxonomyTerms.index')->with('Success', 'Taxonomy term was deleted !');
+ $taxonomyTerm->delete();
+ return redirect()->route('dashboard.taxonomy.terms.index')->with('Success', 'Taxonomy term was deleted !');
} catch (\Exception $ex) {
- Log::error('Failed to delete taxonomy term', ['taxonomyTerms_id' => $taxonomyTerms->id, 'error' => $ex->getMessage()]);
+ Log::error('Failed to delete taxonomy term', ['taxonomyTerm_id' => $taxonomyTerm->id, 'error' => $ex->getMessage()]);
return abort(500);
}
}
-}
-
+}
\ No newline at end of file
diff --git a/app/Http/Livewire/Backend/TaxonomyTable.php b/app/Http/Livewire/Backend/TaxonomyTable.php
index 9d4f3b43..0e2baae4 100644
--- a/app/Http/Livewire/Backend/TaxonomyTable.php
+++ b/app/Http/Livewire/Backend/TaxonomyTable.php
@@ -28,6 +28,8 @@ public function columns(): array
->sortable(),
Column::make("Created at", "created_at")
->sortable(),
+ Column::make("Updated at", "updated_at")
+ ->sortable(),
Column::make("Actions")
];
}
@@ -39,7 +41,7 @@ public function query(): Builder
public function rowView(): string
{
- return 'backend.taxonomies.index-table-row';
+ return 'backend.taxonomy.index-table-row';
}
}
diff --git a/database/factories/TaxonomyTermsFactory.php b/database/factories/TaxonomyTermFactory.php
similarity index 89%
rename from database/factories/TaxonomyTermsFactory.php
rename to database/factories/TaxonomyTermFactory.php
index cb580e2f..117d2123 100644
--- a/database/factories/TaxonomyTermsFactory.php
+++ b/database/factories/TaxonomyTermFactory.php
@@ -1,19 +1,16 @@
@stack('after-scripts')
-
-