public function noticiaInfo($id)
 {
     $noticias = DB::select('select *, DATE_FORMAT(NT_FECHA,\'%d/%m/%Y\') as FECHA from noticias where NT_TIPO = \'detalle\' order by NT_FECHA DESC');
     $noticias = array_slice($noticias, 0, 5);
     $noticia = Noticia::find($id);
     return view('website.noticiaInfo')->with('noticia', $noticia)->with('noticias', $noticias);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     $User = User::all();
     $samples_temp = [];
     for ($i = 0; $i < 50; $i++) {
         $samples_temp[] = ['user' => 1, 'cuerpo' => $faker->text($maxNbChars = 200), 'titulo' => $faker->sentence($nbWords = 4, $variableNbWords = true), 'resumen' => $faker->paragraph($nbSentences = 3, $variableNbSentences = true), 'foto' => 'path', 'carousel' => 'no'];
     }
     Noticia::insert($samples_temp);
 }
 public function index()
 {
     $today = Carbon::today();
     if ($today->day < 15) {
         $inicio = $today->firstOfMonth();
         $futuro = $inicio->addDays(14);
     } else {
         $futuro = $today->lastOfMonth();
     }
     $noticias = Noticia::where('fin', $futuro)->get();
     $tareas = Labor::where('fin', $futuro)->get();
     $user = Auth::user();
     $recursos = Recurso::all();
     //$becario = DB::table('becarios')->where('user_id',$user->id)->first();
     return view('Becario/index', compact('user', 'recursos', 'noticias', 'tareas'));
 }
Esempio n. 4
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     Noticia::creating(function ($noticia) {
         $noticia->slugify();
     });
     Noticia::saving(function ($noticia) {
         if (Request::hasFile('imagen')) {
             $arch = Request::file('imagen');
             Storage::put('noticias/' . $noticia->id . '.' . $arch->getClientOriginalExtension(), File::get($arch));
             $data = File::get($arch);
         }
     });
     User::saving(function ($user) {
         if (Request::has('password')) {
             $user->password = bcrypt(Request::get('password'));
         }
     });
 }
Esempio n. 5
0
 public function update($id_noticia, Request $request)
 {
     $noticia = Noticia::where('id', '=', $id_noticia)->first();
     if (!$request->file('imagem')) {
         $request->merge(['imagem' => $noticia->imagem]);
     }
     if ($noticia->validate($request->all())) {
         list($day, $month, $year) = explode("/", $request->created_at);
         $request->merge(['created_at' => $year . '-' . $month . '-' . $day]);
         if ($request->file('imagem')) {
             $imagem = date('dmyhis') . '.' . $request->file('imagem')->guessClientExtension();
             $request->file('imagem')->move(getcwd() . '/uploads/noticias/', $imagem);
             $request->merge(['imagem' => $imagem]);
             $img = Image::make(getcwd() . '/uploads/noticias/' . $imagem);
             $img->fit(600, 400);
             $img->save(getcwd() . '/uploads/noticias/thumb/' . $imagem);
             $noticia->imagem = $imagem;
         }
         $noticia = $noticia->update($request->except('imagem'));
         return redirect(route('listar-noticias'));
     } else {
         return redirect(route('editar-noticia', ['id_noticia' => $id_noticia]))->withInput()->withErrors($noticia->errors());
     }
 }
 /**
  * Show the application welcome screen to the user.
  *
  * @return Response
  */
 public function index()
 {
     $noticias = Noticia::where('carousel', 'si')->get();
     return view('welcome.index', compact('noticias'));
 }
Esempio n. 7
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($slug)
 {
     $noticia = Noticia::where('slug', '=', $slug)->firstOrFail();
     return view('noticias', ["noticia" => $noticia]);
 }
Esempio n. 8
0
 /**
  * Elimina un registro de la tabla noticia - Metodo destroy()
  * Realiza las validaciones usando el recurso \Validator
  * @param  int $id - primary key tabla noticia
  * @return Redirecciona a la vista principal de noticia luego de eliminar el registro
  */
 public function destroy($id)
 {
     $data = array('id_noticia' => "{$id}");
     $rules = array('id_noticia' => 'exists:red_departamental,id_noticia');
     $ifExistsNoticiaInRedDepartamentalTable = \Validator::make($data, $rules);
     if ($ifExistsNoticiaInRedDepartamentalTable->passes()) {
         return \Redirect::route('noticia')->with('ValidationNoticia', 'No se puede eliminar el registro seleccionado ya que la Noticia se encuentra presente en la Red Departamental.!');
     } else {
         $noti = Noticia::find($id)->delete();
         return \Redirect::route('noticia')->with('alert', 'Registro eliminado con exito!');
     }
 }
 public function agregar_noticia(NoticiaRequest $request)
 {
     $today = Carbon::today();
     $noticia = new Noticia();
     $noticia->titulo = $request->input('titulo');
     $noticia->link = $request->input('link');
     $noticia->descripcion = $request->input('text');
     if ($today->day < 15) {
         $inicio = $today->firstOfMonth();
         $futuro = $inicio->addDays(14);
     } else {
         $futuro = $today->lastOfMonth();
     }
     $noticia->fin = $futuro;
     $file = $request->file('file-1');
     $extension = $request->file('file-1')->getClientOriginalExtension();
     $nombre = $request->input('titulo') . '.' . $extension;
     Storage::put('noticias/' . $nombre, \File::get($file));
     $noticia->url_noticia = $nombre;
     $noticia->save();
     return redirect('admin/contenido');
 }
Esempio n. 10
0
 /**
  * Elimina un registro de la tabla noticia - Metodo destroy()
  * Realiza las validaciones usando el recurso \Validator
  * @param  int $id - primary key tabla noticia
  * @return Redirecciona a la vista principal de noticia luego de eliminar el registro
  */
 public function destroy($id)
 {
     $notic = Noticia::find($id)->delete();
     return \Redirect::route('noticia')->with('alert', 'Registro eliminado con exito!');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $noticia = Noticia::find($id);
     $noticia->delete();
     \Storage::delete($noticia->imagen);
     return response()->json(['success' => true, 'message' => 'Noticia "' . $noticia->titulo . '" eliminada correctamente', 'id' => $noticia->id]);
 }
Esempio n. 12
0
 public function registrarMail(Request $request)
 {
     $mail = new DataMails();
     $mail['mail'] = $request['email'];
     $mail->save();
     $mensaje = 'Se suscribio correctamente.';
     $noticia = Noticia::findOrFail($request['id']);
     return view('noticia.show', compact('noticia', 'mensaje'));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $noticia = Noticia::findOrFail($id);
     $noticia->delete();
     session::flash('message', 'Noticia eliminado de los registros');
     return redirect()->route('admin.noticia.index');
 }
 public function getNoticiasView($id)
 {
     $noticia = Noticia::findOrFail($id);
     return view('guest.noticias.vista', compact('noticia'));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $noticia = Noticia::findOrFail($id);
     $archivo = $noticia->NT_IMAGEN;
     DB::table('noticias')->where('NT_ID', '=', $id)->delete();
     \Storage::disk('noticias')->delete($archivo);
     return Redirect::to('adminpage/Boletin')->with('notice', 'Elemento Eliminado exitosamente!.');
 }
 public function postDestroy(Request $request)
 {
     //abort(500);
     $noticia = Noticia::findOrFail($request->get('id'));
     $noticia->delete();
     $message = ' La noticia ' . $noticia->titulo . ' ha sido eliminada';
     //	dd($request->all());
     if ($request->ajax()) {
         //	return($message);
         return response()->json(['message' => $message]);
     }
     \Session::flash('message', $message);
     return redirect('noticias');
     //return redirect()->route('beneficios.index');
 }
Esempio n. 17
0
 public function index()
 {
     $noticias = Noticia::all()->sortByDesc('id')->take(6);
     $cont = 0;
     return view('layout.indexsoever', compact('noticias', 'cont'));
 }