public function postCancel(Request $request)
    {
        $item = Item::findOrFail($request->input('item_id'));

        if ($item->userId != Auth::user()->userId) {
            return redirect()->back()->withErrors(['You can only end your own items.']);
        }

        if ($item->endDate < time()) {
            return redirect()->back()->withErrors(['This item has already ended.']);
        }

        $item->cancel();

        return redirect('/inventory/unsold')
            ->withStatus($item->name.' has been cancelled.');
    }
public function postCancel(Request $request)
    {
        $item = Item::findOrFail($request->input('item_id'));

        if ($item->userId != Auth::user()->userId) {
            return redirect()->back()->withErrors(['You can only end your own items.']);
        }

        if ($item->endDate < time()) {
            return redirect()->back()->withErrors(['This item has already ended.']);
        }

        $item->cancel();

        return redirect('/inventory/unsold')
            ->withStatus($item->name.' has been cancelled.');
    }
public function postCancel ( Request $ request ) { $ item = Item :: findOrFail ( $ request -> input ( 'item_id' ) ) ; if ( $ item -> userId != Auth :: user ( ) -> userId ) { return redirect ( ) -> back ( ) -> withErrors ( [ 'You can only end your own items.' ] ) ; } if ( $ item -> endDate < time ( ) ) { return redirect ( ) -> back ( ) -> withErrors ( [ 'This item has already ended.' ] ) ; } $ item -> cancel ( ) ; return redirect ( '/inventory/unsold' ) -> withStatus ( $ item -> name . ' has been cancelled.' ) ; }
Cancel an item.

@param \Illuminate\Http\Request $request

@return \Illuminate\Http\RedirectResponse
Cancel an item .