mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-02-02 09:47:49 +00:00
72 - Extracting a Finder Method
This commit is contained in:
@@ -9,7 +9,7 @@ class OrdersController extends Controller
|
||||
{
|
||||
public function show($confirmationNumber)
|
||||
{
|
||||
$order = Order::where('confirmation_number', $confirmationNumber)->first();
|
||||
$order = Order::findByConfirmationNumber($confirmationNumber);
|
||||
return view('orders.show', ['order' => $order]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,11 @@ class Order extends Model
|
||||
return $order;
|
||||
}
|
||||
|
||||
public static function findByConfirmationNumber($confirmationNumber)
|
||||
{
|
||||
return self::where('confirmation_number', $confirmationNumber)->firstOrFail();
|
||||
}
|
||||
|
||||
public function concert()
|
||||
{
|
||||
return $this->belongsTo(Concert::class);
|
||||
|
||||
Reference in New Issue
Block a user