v0.9.10 - Added wants_emails
This commit is contained in:
parent
7b52c43a05
commit
bd0d504ab8
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
|||
|
||||
use App\Event;
|
||||
use App\News;
|
||||
use App\Notification;
|
||||
use App\UserEvent;
|
||||
use App\User;
|
||||
use Illuminate\Http\Request;
|
||||
|
@ -213,11 +214,22 @@ class EventController extends Controller
|
|||
$UserEvent->delete();
|
||||
return redirect()->route("events.signups", [ "event" => $id ]);
|
||||
} else { // Else if you are deleting an event. Then delete all the sign ups AND the event
|
||||
$UserEvent = UserEvent::where('event_id', $id);
|
||||
$UserEvent->delete();
|
||||
|
||||
$UserEvents = UserEvent::where('event_id', $id);
|
||||
$event = Event::find($id);
|
||||
|
||||
foreach ($UserEvents as $userEvent) {
|
||||
$notification = new Notification();
|
||||
|
||||
$notification->user_id = $userEvent->user_id;
|
||||
$notification->message = $event->name . " - ";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$UserEvents->delete();
|
||||
$event->delete();
|
||||
|
||||
return redirect()->route("events.index");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ class NewsController extends Controller
|
|||
$news->type_id = '1';
|
||||
$news->save();
|
||||
|
||||
Helpers::sendNewsNotification($news, User::all());
|
||||
Helpers::sendNewsNotification($news, User::query()->where("wants_emails", "=", true)->get());
|
||||
|
||||
return redirect()->route("news.index");
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ class NewsController extends Controller
|
|||
{
|
||||
$news->save();
|
||||
|
||||
Helpers::sendNewsNotification($news, User::all());
|
||||
Helpers::sendNewsNotification($news, User::query()->where("wants_emails", "=", true)->get());
|
||||
|
||||
return $news;
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ class NewsController extends Controller
|
|||
|
||||
$news->update($data);
|
||||
|
||||
Helpers::sendNewsNotification($news, User::all());
|
||||
Helpers::sendNewsNotification($news, User::query()->where("wants_emails", "=", true)->get());
|
||||
|
||||
return redirect()->route("news.index");
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ class NewsController extends Controller
|
|||
{
|
||||
$news->update();
|
||||
|
||||
Helpers::sendNewsNotification($news, User::all());
|
||||
Helpers::sendNewsNotification($news, User::query()->where("wants_emails", "=", true)->get());
|
||||
|
||||
return $news;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ class CreateUsersTable extends Migration
|
|||
$table->integer("phone")->unique();
|
||||
$table->rememberToken();
|
||||
$table->foreignId("resource_id")->nullable()->constrained("resources", "id");
|
||||
$table->boolean("wants_emails")->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue