/** * Run the database seeds. * * @return void */ public function run() { $subscribers = Subscriber::all(); foreach ($subscribers as $subscriber) { $uuid = hashSubscriber($subscriber->id); $subscriber->uuid = $uuid; $subscriber->save(); } }
/** * Stores bulk subscribers create request. * * @param \Illuminate\Http\Request $request */ public function store(Request $request, $userId, $subscribersListId) { $subscribers = Input::get('subscribers'); $list = SubscribersList::find($subscribersListId); foreach ($subscribers as $subscriber) { if ($list->subscribers()->where('email', $subscriber['email'])->count() == 0) { $subscriber['status'] = 'Active'; $subscriber = Subscriber::create($subscriber); $subscriber->uuid = hashSubscriber($subscriber->id); $subscriber->save(); $subscriber->subscribers_lists()->attach($subscribersListId); } } }