/** * Store a newly created resource in storage. * * @return Response */ public function store(AdtypeRequest $request) { $inputs = $this->getAdtypeInputs($request); $adtype = Adtype::create($inputs); $this->attachToSubscriptions($adtype); $this->attachToUsers($adtype); return redirect()->route('zxadmin.adtype.edit', $adtype->id); }
public function updateAdtype(Ad $ad, Adtype $adtype, AdtypeRequest $request) { $inputs = $request->all(); if ($ad->adtype_id != $adtype->id) { abort(400); } if ($adtype->is_customized) { unset($inputs['title']); $adtype->update($inputs); } else { $inputs['is_customized'] = 1; $adtype = Adtype::create($inputs); $ad->adtype()->associate($adtype)->save(); } $nbrDays = $ad->adtype->nbr_days; $ad->expired_at = $nbrDays >= 9999 ? null : $ad->published_at->addDays($nbrDays + 1); $ad->save(); return redirect()->route('zxadmin.ad.index'); }
protected function createGold() { Adtype::create(['title' => 'Gold', 'is_headline' => true, 'can_renew' => true, 'can_edit' => true, 'can_add_pic' => true, 'can_update_pic' => true, 'nbr_pic' => 10, 'nbr_days' => 90, 'can_add_video' => true, 'nbr_video' => 5, 'can_update_video' => true, 'price' => 4]); }