feat: Implement order and invoice management, enhance addon features, and remove the 'Type' module.
This commit is contained in:
@@ -8,13 +8,15 @@ use App\Models\Addon;
|
||||
use App\Repositories\Addon\AddonRepositoryInterface;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class AddonController extends Controller
|
||||
{
|
||||
//
|
||||
public function __construct(
|
||||
public AddonRepositoryInterface $addonRepository
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
$addOns = $this->addonRepository->filter(
|
||||
@@ -46,13 +48,13 @@ class AddonController extends Controller
|
||||
return back()->withErrors($error->getMessage());
|
||||
}
|
||||
|
||||
return redirect()->route('addon.index')->with('success', 'Added successfully');
|
||||
return redirect()->route('addon.index')->with('success', 'Added successfully');
|
||||
}
|
||||
public function edit($id = 0)
|
||||
{
|
||||
|
||||
$addon = $this->addonRepository->find($id);
|
||||
if (! $addon) {
|
||||
if (!$addon) {
|
||||
return back()->withErrors('Invalid request');
|
||||
}
|
||||
|
||||
@@ -63,7 +65,7 @@ class AddonController extends Controller
|
||||
public function update(int $id = 0, AddOnRequest $request)
|
||||
{
|
||||
$addon = $this->addonRepository->find($id);
|
||||
if (! $addon) {
|
||||
if (!$addon) {
|
||||
return back()->withErrors('Invalid request');
|
||||
}
|
||||
$request->validated();
|
||||
@@ -77,12 +79,12 @@ class AddonController extends Controller
|
||||
return back()->withErrors($error->getMessage());
|
||||
}
|
||||
|
||||
return redirect()->route('addon.index')->with('success', 'Updated successfully');
|
||||
return redirect()->route('addon.index')->with('success', 'Updated successfully');
|
||||
}
|
||||
public function destroy($id)
|
||||
{
|
||||
$addon = $this->addonRepository->find($id);
|
||||
if (! $addon) {
|
||||
if (!$addon) {
|
||||
return back()->withErrors('Invalid request');
|
||||
}
|
||||
DB::beginTransaction();
|
||||
@@ -96,4 +98,26 @@ class AddonController extends Controller
|
||||
|
||||
return redirect()->route('addon.index')->with('success', 'Deleted successfully');
|
||||
}
|
||||
|
||||
|
||||
public function datatable(Request $request)
|
||||
{
|
||||
$query = $this->addonRepository->filter(
|
||||
$request->all(),
|
||||
[],
|
||||
[],
|
||||
['*'],
|
||||
true
|
||||
);
|
||||
|
||||
return DataTables::eloquent($query)
|
||||
->addColumn(
|
||||
'action',
|
||||
function ($d) {
|
||||
return view('administrator.pages.addon.datatable.action', ['row' => $d])->render();
|
||||
}
|
||||
)
|
||||
->rawColumns(['status', 'action'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ use App\Http\Requests\Product\ProductRequest;
|
||||
use App\Http\Services\ProductService;
|
||||
use App\Repositories\Group\GroupRepositoryInterface;
|
||||
use App\Repositories\Admin\Product\ProductRepositoryInterface;
|
||||
use App\Repositories\Type\TypeRepositoryInterface;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
use Exception;
|
||||
@@ -16,7 +16,6 @@ use Exception;
|
||||
class ProductController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
public TypeRepositoryInterface $typeRepository,
|
||||
public GroupRepositoryInterface $groupRepository,
|
||||
public ProductRepositoryInterface $productRepository,
|
||||
public ProductService $productService
|
||||
@@ -31,7 +30,7 @@ class ProductController extends Controller
|
||||
'page' => $request->get('page') ?? 1
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
$title = "List All Product";
|
||||
|
||||
return view('administrator.pages.product.index', compact('title', 'products'));
|
||||
@@ -43,7 +42,7 @@ class ProductController extends Controller
|
||||
$title = 'Add new product';
|
||||
// Fetch Product Categories instead of generic groups
|
||||
$group = \App\Models\ProductCategories::where('is_active', \App\Enums\Status::ACTIVE->value)->get();
|
||||
$type = $this->typeRepository->getAll();
|
||||
$type = null;
|
||||
|
||||
// Fetch OS versions with their group for the OS selector component
|
||||
$osVersions = \App\Models\Os::with('osGroup')->where('status', 1)->get();
|
||||
@@ -93,7 +92,7 @@ class ProductController extends Controller
|
||||
|
||||
$title = 'Edit product: ' . $product->name;
|
||||
$group = \App\Models\ProductCategories::where('is_active', \App\Enums\Status::ACTIVE->value)->get();
|
||||
$type = $this->typeRepository->getAll();
|
||||
$type = null;
|
||||
|
||||
// Fetch OS versions for select
|
||||
$osVersions = \App\Models\Os::with('osGroup')->where('status', 1)->get();
|
||||
|
||||
Reference in New Issue
Block a user