我有user
并且我创建了一个个人资料按钮,例如每个用户都可以查找他们的数据。
在UserController.php
我有这个功能:
/*
* @Get("user/profile/{id}")
*/
public function profile($id)
{
$user = User::find($id);
return view('user.profile', ['user' => $user]);
}
我从这样的观点来称呼它:
<ul class="dropdown-menu">
<li>
<?= link_to('user/profile/'.Auth::user()->id, $title = 'Perfil'); ?>
</li>
@if(Auth::user()->type_id == 1)
<li><a href="{!!URL::to('/user')!!}">Administrar</a></li>
@endif
<li role="separator" class="divider"></li>
<li><a href="{!!URL::to('/logout')!!}"><i class="fa fa-sign-out fa-fw"></i>Logout</a></li>
</ul>
该按钮会将我带到我想要的网址,例如/user/profile/6
,但它会向我发送此错误:
RouteCollection.php第161行中的NotFoundHttpException:
答案 0 :(得分:0)
很难说路线目前在哪里,但我会更改线路:
<li>
<?= link_to('user/profile/'.Auth::user()->id, $title = 'Perfil'); ?>
</li>
到blade
版本:
<li><a href="{!! url("/user/profile/".Auth::user()->id) !!}">Profile</a></li>
另外,请确保您在route
中找到与routes.php
匹配的Route::get("/user/profile/{id}", "UsersController@profile");
:
<?= link_to(); ?>
老实说,我不确定为什么要在同一页面上混合使用{!! url() !!}
和public class DetailsActivity extends Activity {
private TouchImageView imageView;
PhotoViewAttacher mAttacher;
ShareActionProvider mShareActionProvider;
File file;
Intent shareIntent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_details);
Intent i = getIntent();
String image = i.getStringExtra("image");
//Set image url
imageView = (TouchImageView) findViewById(R.id.grid_item_image);
Picasso.with(DetailsActivity.this).load(image).into(imageView);
Uri bmpUri = getLocalBitmapUri(imageView);
shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setType("image/*");
shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
}
@Override
public void onBackPressed() {
deleteDirectoryTree(file);
super.onBackPressed();
}
public static void deleteDirectoryTree(File fileOrDirectory) {
if (fileOrDirectory.isDirectory()) {
for (File child : fileOrDirectory.listFiles()) {
deleteDirectoryTree(child);
}
}
fileOrDirectory.delete();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.full_screen, menu);
MenuItem item = menu.findItem(R.id.menu_item_share);
mShareActionProvider = (ShareActionProvider) item.getActionProvider();
if (mShareActionProvider != null) {
mShareActionProvider.setShareIntent(shareIntent);
}
return true;
}
// Returns the URI path to the Bitmap displayed in specified ImageView
public Uri getLocalBitmapUri(ImageView imageView) {
// Extract Bitmap from ImageView drawable
Drawable drawable = imageView.getDrawable();
Bitmap bmp = null;
if (drawable instanceof BitmapDrawable){
bmp = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
} else {
return null;
}
// Store image to default external storage directory
Uri bmpUri = null;
try {
file = new File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DOWNLOADS), "share_image_" + System.currentTimeMillis() + ".png");
file.getParentFile().mkdirs();
FileOutputStream out = new FileOutputStream(file);
bmp.compress(Bitmap.CompressFormat.PNG, 90, out);
out.close();
bmpUri = Uri.fromFile(file);
} catch (IOException e) {
e.printStackTrace();
}
return bmpUri;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
刀片式语法...无论哪种方式,这都可以解决您的问题。
答案 1 :(得分:0)
THanks,刚修好它的问题是在没有得到注释的用户控制器中,它应该是这样的:
/**
* @Get("user/profile/{id}")
*/
public function profile($id)
{
$user = User::find($id);
return view('user.profile', ['user' => $user]);
}
它似乎是相同的,它只是悼念中的第二个*,就像那个傻。