Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MailingsSeeder extends Seeder
- {
- public function run()
- {
- foreach(Conference::all() as $conference)
- {
- $this->insertIfNotExists($conference, SpeakersWhichDontHasPhoto::class, 'Докладчики, прошедшие в программу, без фотографии');
- $this->insertIfNotExists($conference, AllSpeakers::class, 'Всем подавшим заявки на доклады');
- $this->insertIfNotExists($conference, SpeakersInProgram::class, 'Докладчики, прошедшие в программу');
- $this->insertIfNotExists($conference, SpeakersNotInProgram::class, 'Докладчики, НЕ прошедшие в программу');
- $this->insertIfNotExists($conference, SpeakersDidntTouchQuestionnaire::class, 'Докладчики, не заполнявшие анкету');
- $this->insertIfNotExists($conference, OrdersEmptyFullName::class, 'Заказчики с пустыми ФИО на бейджах');
- }
- }
- private function insertIfNotExists(Conference $conference, $strategy, $title)
- {
- if(InternalMailing::whereIdConference($conference->id)->whereUsersGainingStrategyClass($strategy)->count() == 0)
- {
- $mailing = new InternalMailing();
- $mailing->id_conference = $conference->id;
- $mailing->users_gaining_strategy_class = $strategy;
- $mailing->title = $title;
- $mailing->text = '';
- $mailing->save();
- }
- else
- {
- $mailing = InternalMailing::whereIdConference($conference->id)->whereUsersGainingStrategyClass($strategy)->first();
- $mailing->title = $title;
- $mailing->save();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement