Advertisement
Guest User

Untitled

a guest
May 10th, 2020
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.78 KB | None | 0 0
  1. class MailingsSeeder extends Seeder
  2. {
  3.     public function run()
  4.     {
  5.         foreach(Conference::all() as $conference)
  6.         {
  7.             $this->insertIfNotExists($conference, SpeakersWhichDontHasPhoto::class, 'Докладчики, прошедшие в программу, без фотографии');
  8.             $this->insertIfNotExists($conference, AllSpeakers::class, 'Всем подавшим заявки на доклады');
  9.             $this->insertIfNotExists($conference, SpeakersInProgram::class, 'Докладчики, прошедшие в программу');
  10.             $this->insertIfNotExists($conference, SpeakersNotInProgram::class, 'Докладчики, НЕ прошедшие в программу');
  11.             $this->insertIfNotExists($conference, SpeakersDidntTouchQuestionnaire::class, 'Докладчики, не заполнявшие анкету');
  12.             $this->insertIfNotExists($conference, OrdersEmptyFullName::class, 'Заказчики с пустыми ФИО на бейджах');
  13.         }
  14.     }
  15.  
  16.     private function insertIfNotExists(Conference $conference, $strategy, $title)
  17.     {
  18.         if(InternalMailing::whereIdConference($conference->id)->whereUsersGainingStrategyClass($strategy)->count() == 0)
  19.         {
  20.             $mailing = new InternalMailing();
  21.             $mailing->id_conference = $conference->id;
  22.             $mailing->users_gaining_strategy_class = $strategy;
  23.             $mailing->title = $title;
  24.             $mailing->text = '';
  25.             $mailing->save();
  26.         }
  27.         else
  28.         {
  29.             $mailing = InternalMailing::whereIdConference($conference->id)->whereUsersGainingStrategyClass($strategy)->first();
  30.             $mailing->title = $title;
  31.             $mailing->save();
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement