PHP 8.2.30
Preview: ServiceController.php Size: 5.54 KB
/proc/thread-self/root/home/byroehnu/easetack.com/app/Http/Controllers/Admin/ServiceController.php

<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\Services\ServiceSlugUpdateRequest;
use App\Http\Resources\Admin\CaseStudyUrlResource;
use App\Http\Resources\Admin\CategoryResource;
use App\Http\Resources\Admin\PortfoliosUrlResource;
use App\Http\Resources\Admin\ServicesUrlResource;
use App\Http\Resources\Admin\TeamsUrlResource;
use App\Http\Resources\PricingPlanUrlResource;
use App\Models\CaseStudy;
use App\Models\Portfolio;
use App\Models\PricingPlan;
use App\Models\Service;
use App\Models\ServiceCategory;
use App\Models\Setting;
use App\Models\Team;
use App\Repositories\Admin\ServiceRepository;
use App\Repositories\SettingRepository;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;

class ServiceController extends Controller
{

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

    /**
     * Paginate search result
     */
    public function index(Request $request, ServiceRepository $repository)
    {
        if (Setting::pull("is_enabled_services") === "0") {
            abort(404);
        }

        $data['search'] = $request->search ?: '';
        $data['sort']['column'] = $request->sort['column'] ?? 'id';
        $data['sort']['order'] = $request->sort['order'] ?? 'desc';
        $data['filter']['category'] = $request->filter['category'] ?? 'All Categories';
        $data['categories'] = ServiceCategory::with('content')->get();
        $data['languages'] = json_decode(Setting::pull('languages'));
        $data['filtered_lang'] = $request->filter['lang'] ?? Setting::pull('default_lang');
        $data['services'] = $repository->paginateSearchResult($data['search'], $data['sort'], $data['filter']);
        return Inertia::render('Services/Index', $data);
    }

    /**
     * Create services
     */
    public function create(): Response
    {
        if (Setting::pull("is_enabled_services") === "0") {
            abort(404);
        }

        $data['default_lang'] = Setting::pull('default_lang');
        $data['categories'] = CategoryResource::collection(ServiceCategory::all());
        $data['pricing_plans'] = PricingPlanUrlResource::collection(PricingPlan::with('content')->get());
        $data['case_studies'] = CaseStudyUrlResource::collection(CaseStudy::with('content')->get());
        $data['services'] = ServicesUrlResource::collection(Service::with('content')->get());
        $data['portfolios'] = PortfoliosUrlResource::collection(Portfolio::with('content')->get());
        $data['teams'] = TeamsUrlResource::collection(Team::with('content')->get());
        return Inertia::render('Services/Create', $data);
    }

    /**
     * Store service
     */
    public function store(Request $request, ServiceRepository $repository, SettingRepository $settingRepository): RedirectResponse
    {
        $repository->store($request, $settingRepository);

        return redirect()->route('admin.services.index')->with('success', 'Service successfully created');
    }

    /**
     * Edit service
     */
    public function edit(Service $service, ServiceRepository $repository): Response
    {
        if (Setting::pull("is_enabled_services") === "0") {
            abort(404);
        }

        $data = $repository->getServiceData($service);
        $data['categories'] = CategoryResource::collection(ServiceCategory::all());
        $data['default_lang'] = Setting::pull('default_lang');
        $data['sections'] = $service->sections;
        $data['service'] = $service;
        $data['pricing_plans'] = PricingPlanUrlResource::collection(PricingPlan::with('content')->get());
        $data['case_studies'] = CaseStudyUrlResource::collection(CaseStudy::with('content')->get());
        $data['services'] = ServicesUrlResource::collection(Service::with('content')->get());
        $data['portfolios'] = PortfoliosUrlResource::collection(Portfolio::with('content')->get());
        $data['teams'] = TeamsUrlResource::collection(Team::with('content')->get());
        return Inertia::render('Services/Edit', $data);
    }

    /**
     * Update services
     */
    public function update(Request $request, Service $service, ServiceRepository $repository): RedirectResponse
    {
        $repository->update($request, $service);

        return redirect()->route('admin.services.index')->with('success', 'Service successfully updated');
    }

    /**
     * Service destroy
     */
    public function destroy(Service $service, ServiceRepository $repository): RedirectResponse
    {
        $repository->destroy($service);

        return redirect()->route('admin.services.index')->with('success', 'Service successfully deleted');
    }

    /**
     * bulk delete
     */
    public function bulkDelete(Request $request, ServiceRepository $repository): RedirectResponse
    {
        $repository->bulkDelete($request);

        return redirect()->route('admin.services.index')->with('success', 'Selected services successfully deleted');
    }

    /**
     * update slug
     */
    public function updateSlug(ServiceSlugUpdateRequest $request, Service $service, ServiceRepository $repository): RedirectResponse
    {
        $repository->updateSlug($request, $service);

        return back()->with('success', 'Service slug updated successfully!');
    }

    public function clone(Service $service, ServiceRepository $repository)
    {
        $repository->clone($service);

        return back()->with('success', 'Service successfully cloned');
    }
}

Directory Contents

Dirs: 0 × Files: 40

Name Size Perms Modified Actions
1.15 KB lrw-rw-rw- 2025-05-04 10:56:26
Edit Download
3.88 KB lrw-rw-rw- 2025-05-08 11:48:26
Edit Download
5.44 KB lrw-rw-rw- 2025-05-08 11:48:26
Edit Download
3.97 KB lrw-rw-rw- 2025-05-01 09:00:37
Edit Download
1.95 KB lrw-rw-rw- 2025-05-01 09:00:37
Edit Download
1.91 KB lrw-rw-rw- 2025-05-01 09:00:37
Edit Download
3.00 KB lrw-rw-rw- 2025-05-08 11:48:26
Edit Download
2.07 KB lrw-rw-rw- 2025-05-01 09:00:37
Edit Download
1.09 KB lrw-rw-rw- 2025-05-01 09:00:37
Edit Download
411 B lrw-rw-rw- 2025-04-08 04:12:56
Edit Download
1.66 KB lrw-rw-rw- 2025-05-05 10:37:43
Edit Download
2.75 KB lrw-rw-rw- 2025-05-01 09:00:37
Edit Download
3.09 KB lrw-rw-rw- 2025-05-15 11:24:11
Edit Download
4.47 KB lrw-rw-rw- 2025-05-01 09:00:37
Edit Download
1.89 KB lrw-rw-rw- 2025-05-01 09:00:37
Edit Download
4.12 KB lrw-rw-rw- 2025-05-08 11:48:26
Edit Download
5.40 KB lrw-rw-rw- 2025-05-17 12:58:43
Edit Download
169 B lrw-rw-rw- 2025-04-19 04:22:19
Edit Download
1.01 KB lrw-rw-rw- 2025-04-19 04:22:19
Edit Download
3.82 KB lrw-rw-rw- 2025-05-08 11:48:26
Edit Download
5.51 KB lrw-rw-rw- 2025-05-08 11:48:26
Edit Download
5.19 KB lrw-rw-rw- 2025-05-01 09:00:37
Edit Download
3.20 KB lrw-rw-rw- 2025-05-01 09:00:37
Edit Download
3.59 KB lrw-rw-rw- 2025-05-08 11:48:26
Edit Download
3.52 KB lrw-rw-rw- 2025-05-08 11:48:26
Edit Download
2.54 KB lrw-rw-rw- 2025-05-08 11:48:26
Edit Download
1.18 KB lrw-rw-rw- 2025-05-08 11:48:26
Edit Download
2.79 KB lrw-rw-rw- 2025-05-01 09:00:37
Edit Download
459 B lrw-rw-rw- 2025-04-19 04:22:18
Edit Download
3.74 KB lrw-rw-rw- 2025-05-08 11:48:26
Edit Download
5.54 KB lrw-rw-rw- 2025-05-08 11:48:26
Edit Download
5.50 KB lrw-rw-rw- 2025-05-01 09:00:37
Edit Download
1.78 KB lrw-rw-rw- 2025-05-01 09:00:37
Edit Download
1.77 KB lrw-rw-rw- 2025-05-01 09:00:37
Edit Download
4.79 KB lrw-rw-rw- 2025-05-08 11:48:26
Edit Download
2.98 KB lrw-rw-rw- 2025-04-19 04:22:19
Edit Download
847 B lrw-rw-rw- 2025-04-08 04:12:56
Edit Download
2.32 KB lrw-rw-rw- 2025-05-01 09:00:37
Edit Download
1.77 KB lrw-rw-rw- 2025-05-01 09:00:37
Edit Download
2.63 KB lrw-rw-rw- 2025-05-01 09:00:37
Edit Download

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