Commit 52f77418 authored by Artem's avatar Artem

add queue for sending order confirmation using database driver

parent 674f8f68
......@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Jobs\SendOrderConfirmation;
use App\Mail\OrderConfirmation;
use App\Order;
use App\OrderDetail;
......@@ -49,8 +50,9 @@ class OrderController extends Controller
// ->subject('Order subject');
// });
Mail::to($order->user->email)
->send(new OrderConfirmation($order->id));
->queue(new OrderConfirmation($order->id));
return redirect('cart')->with('order_id', $order->id);
}
......
......@@ -30,7 +30,7 @@ class OrderConfirmation extends Mailable
*/
public function build()
{
return $this->view('emails.order-confirmation')
return $this->text('emails.order-confirmation')
->subject('Order confirmation ' . $this->order_id);
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateJobsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('jobs', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('jobs');
}
}
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<p>Thank you for order. Your order number is {{ $order_id }}. We will contact you shortly.</p>
</body>
</html>
Thank you for order. Your order number is {{ $order_id }}. We will contact you shortly.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment