private function migrateTouches($currentCampaign, $destinationCampaign) { $touch = Touch::create(["title" => $currentCampaign->name, "campaign_id" => $destinationCampaign->id, "template" => $currentCampaign->template, "title_slug" => $currentCampaign->title_slug]); \DB::table('emails')->where('campaign_id', $currentCampaign->id)->update(['touch_id' => $touch->id, 'campaign_id' => $destinationCampaign->id]); DB::table('actions')->where('campaign_id', $currentCampaign->id)->update(['touch_id' => $touch->id, 'campaign_id' => $destinationCampaign->id]); $lastEmail = Email::where('touch_id', '=', $touch->id)->orderBy('send_on', 'DESC')->first(); if ($lastEmail) { $touch->send_on = $lastEmail->send_on; $touch->save(); } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(TouchRequest $request) { if (!strtotime($request->input('send_on'))) { return redirect()->back()->withInput()->with('error', 'The send on date was not parseable'); } $send_on = \Carbon\Carbon::parse($request->input('send_on'))->toDateTimeString(); $touch = Touch::create($request->all()); $touch->send_on = $send_on; $touch->title_slug = md5($touch->id); $touch->save(); return redirect()->route('admin.touches.show', $touch->id)->with('message', "Touch {$touch->title} created"); }