duanang58939 2016-08-31 10:31
浏览 17

创建一个视图,登录用户可以搜索其他人的用户名以查看他的个人资料

Routes

Routes for profile and image upload:

 Route::get('profile', 'UserController@profile');
 //route to the users profile
 Route::post('profile', 'UserController@update_avatar');

Route to the profile viewer that I want to create:

 Route::get('/view', 'UserController@getView');

UserController

My profile logic. for avatar upload

public function profile()
{
    return view('profile', array('user'=> Auth::user()) );
}

public function update_avatar(Request $request)
{
    if($request->hasFile('avatar')) {
        $avatar = $request->file('avatar');
        $filename = time().'.'. $avatar->getClientOriginalExtension();

        Image::make($avatar)->resize(300, 300)
            ->save(public_path("/uploads/avatars/$filename"));

        $user = Auth::user();
        $user->avatar = $filename;
        $user->save();
    }

    return view('profile', array('user'=> Auth::user()));
}

// getView function, I have no idea what to put here
public function getView()
{
    return view('view', array('user'=> Auth::user()));
}

My profile view in views.blade.php: I need this to be shown when a user needs to view another profile

<section>  
    <div class="mbr-box mbr-section mbr-section--relative mbr-section--fixed-size mbr-section--full-height mbr-section--bg-adapted mbr-parallax-backgroundr">
        <div class="jumbotron" style="width:800px; height:700px; border-radius:10px; float:left; padding-top:15px; margin-left:20px;">
            <div class="row">
                <div class="col-md-8 col-md-offset-2">
                    <div class="panel panel-default">
                        <div class="col-md-10 col-md-offset-1">
                            <img src="/uploads/avatars/{{$user->avatar}}" style= "padding-top:15px; width:150px; float:left; height:150px; border-radius:50%; margin-right:25px;"> 
                            <h2>{{$user-> name }}'s Profile from {{$user->city}}</h2>

                            <form enctype="multipart/form-data" action="/profile" method="POST" id="hover">

                                <label>update profile image</label>
                                <input type="file" name="avatar">
                                <input type="hidden" name ="_token" value="{{ csrf_token() }}">
                                <input type="submit" class="pull-right btn-sm btn-default" value="Send Picture">
                            </form><br/>

                            <h1 style="font:sans serif, Helvitica; color:#d1d5d5;"> Taking  {{$user->course}} </h1>
                        </div>
                    </div>
                </div>
            </div>    
        </div>
    </div>
</section>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题