Laravel 5 ProfileController redirecting to Home for some reason

148 views Asked by At

So i'm trying to access a page set on myproject/public/profile which is defined in my routes.php:

Route::get('profile','ProfileController@profile');

(there is no other route for the word 'profile' or that even contains profile)

My profile.blade.php:

@extends('app')
@section('scripts')
@endsection
@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-10 col-md-offset-1">
            <div class="panel panel-default">
                            <?php 
                                 $userid = Input::get('id');
                                 $user = DB::table('users')->where('id',intval($eventid))->first();
                                 $userprofile = DB::table('user_details')->where('user_id',$userid)->first();
                                 ?>
                            <div class="panel-heading"><?php                                    
                                 echo '<b> Profile of ' . $user->first_name . ' ' . $user->last_name . '</b></br>';
                            ?></div>

                            <input class="floatright" type="button" name="addimage" id="addimage" value="Add pictures"/>

            </div>
        </div>
    </div>
</div>
@endsection

My profile controller:

<?php namespace App\Http\Controllers;

class ProfileController extends Controller {

/**
 * Create a new controller instance.
 *
 * @return void
 */
public function __construct()
{
    $this->middleware('guest');
}

    public function getprofile(){
        $userid = Input::get('userid');
        if($userid){
            return view('errors/404');
        }
        $user = DB::table('users').where('id',$userid);
        if(!$user){
            return view('errors/404');
        }

        return view('profile');
    }

}

THE PROBLEM: this is the only page in my entire project that I created myself that is being redirected to myproject/public/home (I'm getting an http 302 reply after my get request) Can anyone see what I'm missing or what could be forcing me to the home page?

1

There are 1 answers

0
jubi4dition On BEST ANSWER

Is this page only for logged in users? Then use

$this->middleware('auth');