請在我的控制器中定義新功能時出現錯誤: 在我的控制器中,我有CRUD方法,如創建,更新,顯示($ id),編輯等。我的問題是:我想定義另一個函數來顯示特定的配置文件(imageprofiles),但它總是會生成一個錯誤,而不是使用imageprofiles()方法,它始終使用crud方法show($ id)。我所有的觀點都是正確的。任何人都可以幫我嗎?提前致謝!Laravel控制器
<?php
class EncodingProfilesController extends \BaseController {
public function index()
{
......}
public function imageprofiles()
{
$Profiles = encodingprofiles::where('type', '=', 'Video')->get();
// show the view and pass the profile to it
return View::make('encodingprofiles.sh')
->with('encodingprofiles', $Profiles);
}
public function show($id)
{
// get the profile
$Profile = encodingprofiles::find($id)->first();
// show the view and pass the profile to it
return View::make('encodingprofiles.show') it tells me that here is the problem Symfony \ Component \ Debug \ Exception \ FatalErrorException
Call to a member function first() on a non-object
->with('encodingprofiles', $Profile);
}
這裏是重定向我到此功能<a href="{{ URL::to('encodingprofiles/imageprofiles') }}">Type</a>
你的'routes.php'看起來像什麼? – zwacky
<?php Route :: controller('users','UsersController'); Route :: resource('encodingprofiles','EncodingProfilesController'); – user3481058