Fix mass messaging (#99)
This commit is contained in:
parent
d256fecaf8
commit
fed1cde69d
|
|
@ -478,13 +478,38 @@ class EventAttendeesController extends MyBaseController
|
|||
$message = Message::createNew();
|
||||
$message->message = $request->get('message');
|
||||
$message->subject = $request->get('subject');
|
||||
$message->recipients = $request->get('recipients');
|
||||
if ($request->get('recipients') != "all") {
|
||||
$message->recipients = $request->get('recipients');
|
||||
}
|
||||
$message->event_id = $event_id;
|
||||
$message->sent_at = new \DateTime();
|
||||
$message->save();
|
||||
|
||||
/*
|
||||
* Add to the queue
|
||||
*/
|
||||
$query = Attendee::where("event_id", $event_id);
|
||||
if ($request->get('recipients') != "all") {
|
||||
$query->where('ticket_id', $request->get('recipients'));
|
||||
}
|
||||
|
||||
$attendees = $query->get();
|
||||
|
||||
|
||||
foreach($attendees as $attendee) {
|
||||
|
||||
$data = [
|
||||
'attendee' => $attendee,
|
||||
'message_content' => $request->get('message'),
|
||||
'subject' => $request->get('subject'),
|
||||
'event' => $attendee->event,
|
||||
'email_logo' => $attendee->event->organiser->full_logo_path,
|
||||
];
|
||||
|
||||
Mail::send('Emails.messageAttendees', $data, function ($message) use ($attendee, $data) {
|
||||
$message->to($attendee->email, $attendee->full_name)
|
||||
->from(config('attendize.outgoing_email_noreply'), $attendee->event->organiser->name)
|
||||
->replyTo($attendee->event->organiser->email, $attendee->event->organiser->name)
|
||||
->subject($data['subject']);
|
||||
});
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
|
|
|
|||
|
|
@ -469,7 +469,7 @@ class CreateUsersTable extends Migration
|
|||
$table->increments('id');
|
||||
$table->text('message');
|
||||
$table->string('subject');
|
||||
$table->integer('recipients'); //ticket_id or 0 for all
|
||||
$table->integer('recipients')->nullable(); //ticket_id or null for all
|
||||
$table->unsignedInteger('account_id')->index();
|
||||
$table->unsignedInteger('user_id');
|
||||
$table->unsignedInteger('event_id');
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use App\Models\Message;
|
||||
|
||||
class FixMessagesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('messages', function ($table) {
|
||||
$table->string('recipients')->nullable()->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Message::where('recipients', null)->delete();
|
||||
Schema::table('messages', function ($table) {
|
||||
$table->string('recipients')->nullable(false)->change();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -44,14 +44,6 @@
|
|||
]) !!}
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="checkbox ">
|
||||
<input type="checkbox" name="send_copy" id="send_copy" value="1">
|
||||
<label for="send_copy"> Send a copy to
|
||||
<strong>{{$event->organiser->email}}</strong></label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group hide">
|
||||
{!! Form::label('sent_time', 'Schedule Send Time', array('class'=>'control-label required')) !!}
|
||||
{!! Form::text('sent_time', Input::old('sent_time'),
|
||||
|
|
|
|||
Loading…
Reference in New Issue