public function noticias()
 {
     $noticias = Noticia::where('NT_TIPO', '=', 'detalle')->orderBy('NT_FECHA')->paginate(15);
     $noticias->setPath('noticia');
     //$noticias = DB::select('select *, DATE_FORMAT(NT_FECHA,\'%d/%m/%Y\') as FECHA from noticias where NT_TIPO = \'detalle\' order by NT_FECHA DESC');
     return view('website.noticia')->with('noticias', $noticias);
 }
 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();
     $user = Auth::user();
     // :::::::::::  Becarios  :::::::::::
     $becarios = User::where('rol', 'becario')->get();
     $activos = User::where('rol', 'becario')->where('activo', '1')->get();
     $mujeres = Becario::where('genero', 'femenino')->get();
     $hombres = Becario::where('genero', 'masculino')->get();
     $total = count($becarios);
     $a = count($activos);
     $m = count($mujeres) * 100 / $a;
     $h = count($hombres) * 100 / $a;
     $s = count(Becario::where('area', 'software')->get()) * 100 / $a;
     $ha = count(Becario::where('area', 'hardware')->get()) * 100 / $a;
     $d = count(Becario::where('area', 'diseño')->get()) * 100 / $a;
     $so = count(Becario::where('area', 'social')->get()) * 100 / $a;
     // :::::::::::  Proyectos  :::::::::::
     $tp = count(Proyecto::all());
     $pa = count(Proyecto::whereBetween('progreso', [1, 99])->get());
     $pt = count(Proyecto::where('progreso', '100')->get());
     return view('Admin/index', compact('user', 'noticias', 'total', 'a', 'm', 'h', 's', 'ha', 'd', 'so', 'tp', 'pa', 'pt'));
 }
 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'));
 }
Beispiel #4
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());
     }
 }
 public function postUpdateCarousel(Request $request)
 {
     $noticia = Noticia::findOrFail($request->id);
     $carousel = Noticia::where('carousel', 'si')->count();
     //cuento los que ya estan en carousel
     if ($request->check == 0) {
         $noticia->carousel = 'no';
         $noticia->save();
         $message = "La noticia se ha quitado del carousel exitosamente";
         $alert = "success";
     } elseif ($request->check == 1) {
         if ($carousel < 5) {
             if ($noticia->foto != 'path') {
                 $noticia->carousel = 'si';
                 $noticia->save();
                 $message = "La noticia ha sido agregada al carousel exitosamente";
                 $alert = 'success';
             } else {
                 $message = "La noticia seleccionada no posee una imagen para el carousel. favor verificar";
                 $alert = 'danger';
             }
         } else {
             $message = "Ya ha alcanzado el maximo de noticias en el carousel";
             $alert = 'danger';
         }
     }
     if ($request->ajax()) {
         //	return($message);
         return response()->json(['message1' => $message, 'alert' => $alert]);
     }
     \Session::flash('message1', $message);
     return redirect('/noticias')->with('message1', $message);
 }
 /**
  * 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'));
 }
 /**
  * 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]);
 }