私は と の初心者のようなものですが、Laravel 4
これSentry 2
まで生き残ることができました。私は現在、問題に直面しています。なぜならuserid(1)
、私がとしてログインしていて、のプロファイルを表示したいのですがuserid(2)
、userid(2) のプロファイルに userid(1) の情報が表示されているだけだからです。
ここでフィルターを使用すると便利な場合があることは承知していますが、正直に言うと。などなど、何を見ればいいのかわからない。
このサイトが回答を提供するためのものではないことは承知しています。しかし、誰かが私にちょっとした答え、どこを見るべきか、何を心に留めておくべきかなどを教えてくれたら、それは非常にありがたいです.
- -編集 - -
ルート:
Route::group(array('before'=>'auth'), function(){
Route::get('logout', 'HomeController@logout');
Route::get('profile/{username}', 'ProfileController@getIndex');
});
Route::filter('auth', function($route)
{
$id = $route->getParameter('id');
if(Sentry::check() && Sentry::getUser()->id === $id) {
return Redirect::to('/');
}
});
プロファイルコントローラー
public function getIndex($profile_uname)
{
if(Sentry::getUser()->username === $profile_uname) {
// This is your profile
return View::make('user.profile.index');
} else {
// This isn't your profile but you may see it!
return ??
}
}
意見
@extends('layouts.userprofile')
@section('title')
{{$user->username}}'s Profile
@stop
@section('notification')
@stop
@section('menu')
@include('layouts.menus.homemenu')
@stop
@section('sidebar')
@include('layouts.menus.profilemenu')
@stop
@section('content')
<div class="col-sm-10 col-md-10 col-xs-10 col-lg-10">
<div class="panel panel-info">
<div class="panel-heading"><h3>{{ $user->username }}</h3></div>
</div>
</div>
@stop
@section('footer')
@stop