mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-02-02 22:48:02 +00:00
82 - Refactoring to a Facade
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Facades\OrderConfirmationNumber;
|
||||
|
||||
class Order extends Model
|
||||
{
|
||||
@@ -11,14 +12,12 @@ class Order extends Model
|
||||
public static function forTickets($tickets, $email, $amount)
|
||||
{
|
||||
$order = self::create([
|
||||
'confirmation_number' => app(OrderConfirmationNumberGenerator::class)->generate(),
|
||||
'confirmation_number' => OrderConfirmationNumber::generate(),
|
||||
'email' => $email,
|
||||
'amount' => $amount,
|
||||
]);
|
||||
|
||||
foreach ($tickets as $ticket) {
|
||||
$order->tickets()->save($ticket);
|
||||
}
|
||||
$order->tickets()->saveMany($tickets);
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user