original_string: public function getDispatched($purchaseId)
      {
          $purchase = Purchase::findOrFail($purchaseId);
  
          if ($purchase->item->seller->userId != Auth::user()->userId) {
              return redirect('/inventory/sold')->withErrors([
                  "You are not seller of this item."
              ]);
          }
  
          if ($purchase->isDispatched()) {
              return redirect('/inventory/sold')->withStatus(
                  'You have already marked this item as dispatched.'
              );
          }
  
          if (!$purchase->deliveryOption) {
              return redirect()->back()->withErrors([
                  "This item is due to be collected."
              ]);
          }
  
          return view('mustard::purchase.dispatched', [
              'purchase' => $purchase,
          ]);
      }
code: public function getDispatched($purchaseId)
      {
          $purchase = Purchase::findOrFail($purchaseId);
  
          if ($purchase->item->seller->userId != Auth::user()->userId) {
              return redirect('/inventory/sold')->withErrors([
                  "You are not seller of this item."
              ]);
          }
  
          if ($purchase->isDispatched()) {
              return redirect('/inventory/sold')->withStatus(
                  'You have already marked this item as dispatched.'
              );
          }
  
          if (!$purchase->deliveryOption) {
              return redirect()->back()->withErrors([
                  "This item is due to be collected."
              ]);
          }
  
          return view('mustard::purchase.dispatched', [
              'purchase' => $purchase,
          ]);
      }
code_tokens: public function getDispatched ( $ purchaseId ) { $ purchase = Purchase :: findOrFail ( $ purchaseId ) ; if ( $ purchase -> item -> seller -> userId != Auth :: user ( ) -> userId ) { return redirect ( '/inventory/sold' ) -> withErrors ( [ "You are not seller of this item." ] ) ; } if ( $ purchase -> isDispatched ( ) ) { return redirect ( '/inventory/sold' ) -> withStatus ( 'You have already marked this item as dispatched.' ) ; } if ( ! $ purchase -> deliveryOption ) { return redirect ( ) -> back ( ) -> withErrors ( [ "This item is due to be collected." ] ) ; } return view ( 'mustard::purchase.dispatched' , [ 'purchase' => $ purchase , ] ) ; }
docstring: Return the purchase dispatched view.
  
  @return \Illuminate\View\View
docstring_tokens: Return the purchase dispatched view .