Example #1
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $user = Auth::user()->role;
     $profile = template::where('user_id', Auth::id())->count();
     if ($profile == 1) {
         return $next($request);
     } else {
         return redirect('/admin/Template/create');
     }
 }
 public function template($slug)
 {
     $restaurant = template::where('slug', $slug)->first();
     $profile = template::where('slug', $slug)->first();
     if ($restaurant->user->role == 1) {
         return view('restaurant.profile', compact('restaurant'));
     }
     if ($profile->user->role == 3) {
         $tatoo = post::where('user_id', $profile->user->id)->OrderBy('id', 'ASC')->paginate(6);
         return view('tatoo.profile', compact('profile', 'tatoo'));
     }
 }
Example #3
0
<?php

/*
|--------------------------------------------------------------------------
| Routes File
|--------------------------------------------------------------------------
|
| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
    $post = \App\post::OrderBy('id', 'ASC')->paginate(9);
    $event = \App\event::OrderBy('id', 'ASC')->paginate(9);
    $user = \App\template::OrderBy('id', 'ASC')->paginate(6);
    return view('welcome', compact('post', 'event', 'user'));
});
Route::get('/load', function () {
    return view('load');
});
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/
Example #4
0
 /**
  * Show the application dashboard.
  *
  * @return Response
  */
 public function index()
 {
     $template = \App\template::where('user_id', \Auth::id())->first();
     return view('home', compact('template'));
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $slug)
 {
     $data = template::findBySlugOrIdOrFail($slug);
     if (Gate::denies('update', $data)) {
         Session::flash('success', 'No puedes editar algo que no es tuyo.');
         return redirect('/admin/Template');
     } else {
         $data->resluggify()->update($request->all());
         Session::flash('success', 'Perfil actualizado correctamente.');
         return redirect('/admin/Template');
     }
 }