PHP 8.2.30
Preview: BrandController.php Size: 3.29 KB
/home/byroehnu/cnggold.com.ng/app/Http/Controllers/Admin/BrandController.php

<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\Products\Brand\BrandStoreRequest;
use App\Http\Requests\Admin\Products\Brand\BrandUpdateRequest;
use App\Models\Brand;
use App\Models\Setting;
use App\Repositories\Admin\BrandRepository;
use Illuminate\Http\Request;
use Inertia\Inertia;

class BrandController extends Controller
{
    public function __construct()
    {
        // for demo mood
        $this->middleware('demo', ['only' => ['destroy', 'store', 'update', 'bulkDelete']]);
    }

    public function index(Request $request, BrandRepository $repository)
    {
        if (Setting::pull("is_enabled_ecommerce") === "0") {
            abort(404);
        }

        $data['search'] = $request->search ?: '';
        $data['sort']['column'] = $request->sort['column'] ?? 'id';
        $data['sort']['order'] = $request->sort['order'] ?? 'desc';
        $data['languages'] = json_decode(Setting::pull('languages'));
        $data['filtered_lang'] = $request->filter['lang'] ?? Setting::pull('default_lang');
        $data['brands'] = $repository->paginateSearchResult($data['search'], $data['sort']);

        return Inertia::render('Products/Brands/Index', $data);
    }

    /**
     * Show the form for creating a new resource.
     */
    public function create()
    {
        if (Setting::pull("is_enabled_ecommerce") === "0") {
            abort(404);
        }

        $data['default_lang'] = Setting::pull('default_lang');
        $data['languages'] = json_decode(Setting::pull('languages'));

        return Inertia::render('Products/Brands/Create', $data);
    }

    /**
     * Store brand
     */
    public function store(BrandStoreRequest $request, BrandRepository $repository)
    {
        $repository->create($request);
        return redirect()->route('admin.brands.index')->with('success', 'Brand successfully created!');
    }

    /**
     * Show the form for editing the specified resource.
     */
    public function edit(Brand $brand, BrandRepository $repository)
    {
        if (Setting::pull("is_enabled_ecommerce") === "0") {
            abort(404);
        }

        $data['brand'] = $repository->getEditData($brand);
        $data['default_lang'] = Setting::pull('default_lang');
        $data['languages'] = json_decode(Setting::pull('languages'));

        return Inertia::render('Products/Brands/Edit', $data);
    }

    /**
     * Update the specified resource in storage.
     */
    public function update(BrandUpdateRequest $request, Brand $brand, BrandRepository $repository)
    {
        try {
            $repository->update($request, $brand);

            return redirect()->route('admin.brands.index')->with('success', 'Brand successfully updated!');
        } catch (\Exception $exception) {
            return back()->with('error', $exception->getMessage());
        }
    }

    /**
     * Remove the specified resource from storage.
     */
    public function destroy(Brand $brand, BrandRepository $repository)
    {
        $repository->destroy($brand);
        return back()->with('success', 'Brand successfully deleted');
    }

    public function bulkDelete(Request $request, BrandRepository $repository)
    {
        $repository->bulkDelete($request->ids);
        return back()->with('success', 'Brand successfully deleted!');
    }
}

Directory Contents

Dirs: 0 × Files: 41

Name Size Perms Modified Actions
1.15 KB lrw-r--r-- 2025-05-04 10:56:26
Edit Download
3.29 KB lrw-r--r-- 2025-07-19 07:29:54
Edit Download
3.88 KB lrw-r--r-- 2025-05-22 03:36:31
Edit Download
5.76 KB lrw-r--r-- 2025-07-19 07:29:54
Edit Download
3.97 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
1.95 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
1.91 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
3.00 KB lrw-r--r-- 2025-05-08 11:48:26
Edit Download
2.07 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
1.09 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
411 B lrw-r--r-- 2025-04-08 04:12:56
Edit Download
1.66 KB lrw-r--r-- 2025-05-05 10:37:43
Edit Download
2.75 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
3.26 KB lrw-r--r-- 2025-05-15 12:02:59
Edit Download
4.47 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
1.89 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
4.12 KB lrw-r--r-- 2025-05-08 11:48:26
Edit Download
5.74 KB lrw-r--r-- 2025-07-19 07:29:54
Edit Download
169 B lrw-r--r-- 2025-04-19 04:22:19
Edit Download
1.01 KB lrw-r--r-- 2025-04-19 04:22:19
Edit Download
3.83 KB lrw-r--r-- 2025-05-22 03:36:31
Edit Download
5.83 KB lrw-r--r-- 2025-07-19 07:29:54
Edit Download
5.19 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
3.20 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
3.59 KB lrw-r--r-- 2025-05-22 13:45:40
Edit Download
3.65 KB lrw-r--r-- 2025-07-19 07:29:54
Edit Download
2.54 KB lrw-r--r-- 2025-05-08 11:48:26
Edit Download
1.18 KB lrw-r--r-- 2025-05-08 11:48:26
Edit Download
2.79 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
459 B lrw-r--r-- 2025-04-19 04:22:18
Edit Download
3.74 KB lrw-r--r-- 2025-05-22 03:36:31
Edit Download
5.86 KB lrw-r--r-- 2025-07-19 07:29:54
Edit Download
5.50 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
1.78 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
1.77 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
5.11 KB lrw-r--r-- 2025-07-19 07:29:54
Edit Download
2.98 KB lrw-r--r-- 2025-04-19 04:22:19
Edit Download
847 B lrw-r--r-- 2025-04-08 04:12:56
Edit Download
2.32 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
1.77 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download
2.63 KB lrw-r--r-- 2025-05-01 09:00:37
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).