/** * Remove the specified post from storage. * * @param int $id * * @return Response */ public function destroy($id) { $post = $this->postRepository->find($id); if (empty($post)) { Flash::error('post no encontrada.'); return redirect(url('home')); } $created = new Carbon($post->created_at); $transcurrido = $created->diffInMinutes(); if (Auth::user()->rol != 'admin' && $transcurrido < 120) { Flash::warning('Deben pasar 2 horas para poder eliminar el Post han pasado ' . $transcurrido . ' minutos desde la creación'); return redirect(url('home')); } $this->postRepository->delete($id); if (file_exists($post->imagen)) { unlink($post->imagen); } if (file_exists($post->archivo)) { unlink($post->archivo); } Flash::success('Post borrado satisfactoriamente.'); return redirect(url('home')); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $post = $this->post->find($id); $post->delete(); return redirect()->back()->with('success_message', 'The ' . $this->post_type . ' has been deleted'); }