-
-
Save adamwathan/b951adfafd805be77da1a5a76d437008 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use App\Purchase; | |
use Illuminate\Support\Facades\Auth; | |
class OrdersController extends Controller | |
{ | |
// ... | |
public function show($id) | |
{ | |
$purchase = Auth::user()->purchases()->with('latestFulfillmentAttempts')->findOrFail($id); | |
return view('orders.show', [ | |
'purchase' => $purchase, | |
'fulfillmentAttempts' => $purchase->latestFulfillmentAttempts, | |
]); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use App\Events\FulfillmentFailed; | |
use Facades\App\CreditCardGateway; | |
use Facades\App\WebhookDispatcher; | |
use Illuminate\Database\Eloquent\Model; | |
use App\Exceptions\WebhookFailedException; | |
class Purchase extends Model | |
{ | |
// ... | |
public function fulfillmentAttempts() | |
{ | |
return $this->hasMany(FulfillmentAttempt::class); | |
} | |
public function latestFulfillmentAttempts() | |
{ | |
return $this->fulfillmentAttempts()->latest(); | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment