PHP 8.2.30
Preview: OrderController.php Size: 4.12 KB
/home/byroehnu/easetack.com/app/Http/Controllers/Admin/OrderController.php

<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\Order;
use App\Models\Setting;
use App\Repositories\Admin\OrderRepository;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Inertia\Inertia;
use PDF;

class OrderController extends Controller
{

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

    /**
     * Display a listing of the resource.
     */
    public function index(Request $request, OrderRepository $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['filter']['status'] = $request->filter['status'] ?? 'All Order Status';
        $data['filter']['payment_status'] = $request->filter['payment_status'] ?? 'All Payment Status';
        $data['orders'] = $repository->paginateSearchResult($data['search'], $data['sort'], $data['filter']);

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

    /**
     * Show the form for showing the specified resource.
     */
    public function show(Order $order)
    {
        if (Setting::pull("is_enabled_ecommerce") === "0") {
            abort(404);
        }

        $data['order'] = $order->load('orderitems');
        return Inertia::render('Orders/Show', $data);
    }

    /**
     * Update the specified resource in storage.
     *
     * @return RedirectResponse
     */
    public function updateStatus(Request $request, Order $order, OrderRepository $repository)
    {
        $repository->updateStatus($request, $order);

        return redirect()->route('admin.orders.index')->with('success', 'Order status successfully updated!');
    }

    /**
     * Show invoice.
     */
    public function showInvoice(Order $order, OrderRepository $repository)
    {
        if (Setting::pull("is_enabled_ecommerce") === "0") {
            abort(404);
        }

        $data['invoice_logo'] = Setting::pull('invoice_logo');
        $data['footer_contact'] = Setting::pull('footer_contact');
        $data['footer_address'] = Setting::pull('footer_address');
        $data['currency_symbol'] = Setting::pull('currency_symbol');
        $data['font_family'] = $repository->getInvoiceFrontName();
        $data['direction'] = $repository->getInvoiceDirection();
        $data['text_align'] = $data['direction'] == 'ltr' ? 'left' : 'right';
        $data['order'] = $order->load('orderitems');
        $pdf = PDF::loadView('invoice', $data);

        return $pdf->stream("invoice-{$order->order_number}.pdf");
    }

    /**
     * Download invoice
     */
    public function downloadInvoice(Order $order, OrderRepository $repository)
    {
        if (Setting::pull("is_enabled_ecommerce") === "0") {
            abort(404);
        }

        $data['invoice_logo'] = Setting::pull('invoice_logo');
        $data['footer_contact'] = Setting::pull('footer_contact');
        $data['footer_address'] = Setting::pull('footer_address');
        $data['currency_symble'] = Setting::pull('currency_symble');
        $data['font_family'] = $repository->getInvoiceFrontName();
        $data['direction'] = $repository->getInvoiceDirection();
        $data['text_align'] = $data['direction'] == 'ltr' ? 'left' : 'right';
        $data['order'] = $order->load('orderitems');
        $pdf = PDF::loadView('invoice', $data);

        return $pdf->download("invoice-{$order->order_number}.pdf");
    }

    /**
     * Remove the specified resource from storage.
     */
    public function destroy(Order $order, OrderRepository $repository)
    {
        $repository->destroy($order);

        return back()->with('success', 'Orders successfully deleted!');
    }

    /**
     * Bulk delete
     */
    public function bulkDelete(Request $request, OrderRepository $repository)
    {
        $repository->bulkDelete($request->ids);

        return back()->with('success', 'Orders successfully deleted!');
    }
}

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).