HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/posscale/www/printmanager/app/Http/Controllers/Tenant/Address.php
<?php

namespace App\Http\Controllers\Tenant;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Requests\AddressRequest;
use App\Models\Address as ModelsAddress;
use App\Models\Customer;
use Illuminate\Support\Facades\Redirect;

class Address extends Controller
{

    /**
     * Show the form for creating a new resource.
     */
    public function create(Customer $customer)
    {
        abort_unless(auth()->user()?->can('manage_customers'), 403);

        $address = '';
        return view('tenant.customers.address.form', [ 'customer' => $customer, 'address' => $address, 'action' => 'Add Address']);
    }

    /**
     * Store a newly created resource in storage.
     */
    public function store(Customer $customer, AddressRequest $request)
    {
        abort_unless(auth()->user()?->can('manage_customers'), 403);

        $validated  = $request->validated();
        $customer   = Customer::find($validated['customer_id']);
        $customer->addresses()->create([
            'address'   => $validated['address'],
            'city'      => $validated['city'],
            'state'     => $validated['state'],
            'zip'     => $validated['zip'],
        ]);


        return Redirect::route('customers.show', $validated['customer_id'])->with('message', 'Address added successfully.');

    }

    /**
     * Display the specified resource.
     */
    public function show(string $id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     */
    public function edit(Customer $customer, ModelsAddress $address)
    {
        abort_unless(auth()->user()?->can('manage_customers'), 403);

        return view('tenant.customers.address.form', [ 'customer' => $customer, 'address' => $address->toArray(), 'action' => 'Edit Address']);
    }

    /**
     * Update the specified resource in storage.
     */
    public function update(Customer $customer, AddressRequest $request, ModelsAddress $address)
    {
        abort_unless(auth()->user()?->can('manage_customers'), 403);

        $validated  = $request->validated();

        $address->address   = $validated['address'];
        $address->city      = $validated['city'];
        $address->state     = $validated['state'];
        $address->zip       = $validated['zip'];
        $address->save();

        return Redirect::route('customers.show', $validated['customer_id'])->with('message', 'Address updated successfully.');

    }

    /**
     * Remove the specified resource from storage.
     */
    public function destroy(Customer $customer,  ModelsAddress $address)
    {
        abort_unless(auth()->user()?->can('manage_customers'), 403);

        $address->delete();
        return Redirect::route('customers.show', $customer->id)->with('message', 'Address delete successfully.');
    }
}