Example #1
0
Route::get('administrador/crear-curso', array('as' => 'crear-curso', 'uses' => 'CursoController@create'));
Route::get('administrador/crear-curso/{id}', array('as' => 'crear-curso-2', 'uses' => 'TemarioController@create'));
Route::get('administrador/crear-inicio/{id}', array('as' => 'crear-curso-4b', 'uses' => 'TemarioController@create1b'));
Route::get('administrador/crear-contenido/{id}', array('as' => 'crear-curso-5', 'uses' => 'TemarioController@create2'));
Route::get('administrador/crear-leccion/{id}', array('as' => 'crear-curso-6', 'uses' => 'LeccionController@create'));
Route::get('administrador/crear-evaluacion/{id}', array('as' => 'crear-curso-7', 'uses' => 'EvaluacionController@create'));
Route::get('administrador/crear-preguntas/{id}', array('as' => 'crear-curso-8', 'uses' => 'PreguntaController@create'));
Route::get('administrador/asignar-color/{id}', array('as' => 'crear-curso-9', function ($id) {
    if (Session::get('user_id') == '') {
        return Redirect::to('index');
    }
    $relaciones = RelacionUsuarioCurso::where('id_usuario', '=', Session::get('user_id'))->where('id_curso', '=', $id)->where('tipo_relacion', '=', 'Profesor Admin')->get();
    if (count($relaciones) == 0 && Session::get('tipo_usuario') != "Administrador") {
        return Redirect::to('index');
    }
    if (Badge::where('id_curso', '=', $id)->count() == 0) {
        DB::table('badge')->insert(array('id_curso' => $id, 'color1' => '#FFFFFF', 'color2' => '#000000'));
    }
    $badge = Badge::find($id);
    $curso = Curso::find($id);
    return View::make('Administrador/asignar-color')->with('curso', $curso)->with('badge', $badge);
}))->where('id', '[0-9]+');
Route::get('administrador/asignar-profesor/{id}', array('as' => 'crear-curso-3', function ($id) {
    if (Session::get('user_id') == '') {
        return Redirect::to('index');
    }
    $relaciones = RelacionUsuarioCurso::where('id_usuario', '=', Session::get('user_id'))->where('id_curso', '=', $id)->where('tipo_relacion', '=', 'Profesor Admin')->get();
    if (count($relaciones) == 0 && Session::get('tipo_usuario') != "Administrador") {
        return Redirect::to('index');
    }
    $profesores = Usuario::all();
Example #2
0
 public function post($slug)
 {
     $post = Post::withTrashed()->where('slug', $slug)->first();
     $nextpost = Post::where('id', '<', $post->id)->orderBy('id', 'desc')->first();
     if (empty($post)) {
         App::abort(404);
     }
     $comments = Comment::where('post_id', $post->id)->where('parent_comment_id', 0)->orderBy('created_at', 'desc')->take(3)->get();
     $attack_comments = Comment::where('post_id', $post->id)->where('type', 'attack')->where('parent_comment_id', 0)->orderBy('created_at', 'desc')->take(3)->get();
     $assist_comments = Comment::where('post_id', $post->id)->where('type', 'assist')->where('parent_comment_id', 0)->orderBy('created_at', 'desc')->take(3)->get();
     $defense_comments = Comment::where('post_id', $post->id)->where('type', 'defense')->where('parent_comment_id', 0)->orderBy('created_at', 'desc')->take(3)->get();
     $post->load(array('votes' => function ($query) {
         $query->where('user_id', Auth::id());
     }));
     $others = Post::orderBy(DB::raw('RAND()'))->take(10)->get();
     $user = User::find($post->user_id);
     $totalposts = Post::where('user_id', $user->id)->count();
     if (!$totalposts) {
         $totalposts = 0;
     }
     $badge = Badge::where('total_posts', '<=', $totalposts)->orderBy('total_posts', 'desc')->first();
     if ($badge) {
         $badgename = $badge->name;
         $badgeimage = $badge->image;
     } else {
         $badgename = '';
         $badgeimage = '';
     }
     $featured = FeaturedPost::where('post_id', $post->id)->first();
     $data = array('page' => 'page', 'post' => $post, 'nextpost' => $nextpost, 'comments' => $comments, 'attacks' => $attack_comments, 'assists' => $assist_comments, 'defenses' => $defense_comments, 'others' => $others, 'posted_by' => $user->username, 'badge_name' => $badgename, 'badge_image' => $badgeimage, 'isfeatured' => !empty($featured) ? true : false);
     return View::make('post2')->with($data);
 }