src/lib/Http/Controllers/AccountController.php
public function postDeletePostalAddress(Request $request)
    {
        $pa = PostalAddress::findOrFail($request->input('postal_address_id'));

        if ($pa->user->userId != Auth::user()->userId) {
            return redirect('/account/postal-addresses')
                ->withErrors(["You can only delete your own postal addresses."]);
        }

        if ($pa->purchases()->count()) {
            return redirect('/account/postal-addresses')
                ->withErrors(["You cannot delete postal addresses that are associated with purchases."]);
        }

        $pa->delete();

        return redirect('/account/postal-addresses')
            ->withStatus('Postal address deleted.');
    }
public function postDeletePostalAddress(Request $request)
    {
        $pa = PostalAddress::findOrFail($request->input('postal_address_id'));

        if ($pa->user->userId != Auth::user()->userId) {
            return redirect('/account/postal-addresses')
                ->withErrors(["You can only delete your own postal addresses."]);
        }

        if ($pa->purchases()->count()) {
            return redirect('/account/postal-addresses')
                ->withErrors(["You cannot delete postal addresses that are associated with purchases."]);
        }

        $pa->delete();

        return redirect('/account/postal-addresses')
            ->withStatus('Postal address deleted.');
    }
public function postDeletePostalAddress ( Request $ request ) { $ pa = PostalAddress :: findOrFail ( $ request -> input ( 'postal_address_id' ) ) ; if ( $ pa -> user -> userId != Auth :: user ( ) -> userId ) { return redirect ( '/account/postal-addresses' ) -> withErrors ( [ "You can only delete your own postal addresses." ] ) ; } if ( $ pa -> purchases ( ) -> count ( ) ) { return redirect ( '/account/postal-addresses' ) -> withErrors ( [ "You cannot delete postal addresses that are associated with purchases." ] ) ; } $ pa -> delete ( ) ; return redirect ( '/account/postal-addresses' ) -> withStatus ( 'Postal address deleted.' ) ; }
Delete a postal address.

@param \Illuminate\Http\Request $request
@return \Illuminate\Http\RedirectResponse
Delete a postal address .