mirror of
https://github.com/brunofontes/shareit.git
synced 2024-11-24 04:14:57 +00:00
Included: alert the active user someone is waiting for the item
This commit is contained in:
parent
a173e3923a
commit
d407e5d109
@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use \App\User;
|
use \App\User;
|
||||||
|
use \App\Mail\UserWaiting;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class AlertController extends Controller
|
class AlertController extends Controller
|
||||||
@ -13,6 +14,13 @@ class AlertController extends Controller
|
|||||||
$item->waiting_user_id = \Auth::id();
|
$item->waiting_user_id = \Auth::id();
|
||||||
$item->timestamps = false;
|
$item->timestamps = false;
|
||||||
$item->save();
|
$item->save();
|
||||||
|
|
||||||
|
$loggedUser = \Auth::user()->name;
|
||||||
|
$userWithItem = User::find($item->used_by);
|
||||||
|
\Mail::to($userWithItem)->send(
|
||||||
|
new UserWaiting($loggedUser, $userWithItem->name, $item)
|
||||||
|
);
|
||||||
|
|
||||||
return redirect('home');
|
return redirect('home');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
40
app/Mail/UserWaiting.php
Normal file
40
app/Mail/UserWaiting.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Mail;
|
||||||
|
|
||||||
|
use \App\Item;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Mail\Mailable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
|
||||||
|
class UserWaiting extends Mailable
|
||||||
|
{
|
||||||
|
public $item;
|
||||||
|
public $waitingUser;
|
||||||
|
public $userWithItem;
|
||||||
|
use Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new message instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct($waitingUser, $userWithItem, Item $item)
|
||||||
|
{
|
||||||
|
$this->item = $item;
|
||||||
|
$this->waitingUser = $waitingUser;
|
||||||
|
$this->userWithItem = $userWithItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the message.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function build()
|
||||||
|
{
|
||||||
|
return $this->subject($this->waitingUser . ' wants to use ' . $this->item->name)
|
||||||
|
->markdown('emails.userWaiting');
|
||||||
|
}
|
||||||
|
}
|
16
resources/views/emails/userWaiting.blade.php
Normal file
16
resources/views/emails/userWaiting.blade.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
@component('mail::message')
|
||||||
|
Hello, {{$userWithItem}},
|
||||||
|
|
||||||
|
Are you still using {{$item->name}}?
|
||||||
|
|
||||||
|
We just want to let you know that {{$waitingUser}} asked us to be alerted when this item were available.
|
||||||
|
|
||||||
|
So, if you are not using it anymore, please go to our site and...
|
||||||
|
|
||||||
|
@component('mail::button', ['url' => 'https://shareit.brunofontes.net/home'])
|
||||||
|
Return it!
|
||||||
|
@endcomponent
|
||||||
|
|
||||||
|
Thanks,<br>
|
||||||
|
{{ config('app.name') }}
|
||||||
|
@endcomponent
|
Loading…
Reference in New Issue
Block a user