/** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { $user = app('auth')->user(); $advert = Adverts::findOrFail($this->id); if ($advert->user_id === $user->id || $user->admin === 1) { return true; } else { return FALSE; } }
public function setAvailable($id) { $advert = Adverts::findOrFail($id); $advert->expired_at = Carbon::now()->addDays(7)->format('Y-m-d'); $advert->update(); \Session::flash('flash_message', 'Ogłoszenie zostało oznaczone jako aktywne!'); return redirect('/adverts/owned'); }