2016-04-28 48 views
0

我控制器文件看起來像這樣未找到控制器方法。在laravel錯誤5.2

<?php 

namespace App\Http\Controllers; 

use App\Artist; 
use App\Song; 
use App\Album; 

class WebsiteController extends Controller 
{ 


    public function getIndex(){ 

     return redirect('/'); 

    } 

    public function getHome(){ 

     $featuredArtist=''; 
     $featuredAlbum=''; 
     $featuredSong=''; 

     return view('website.welcome')->with(array('featuredArtist'=>$featuredArtist,'featuredSong'=>$featuredSong,'featuredAlbum'=>$featuredAlbum)); 

    } 


    public function get_listartist(){ 

    $artistList = Artist::select('id','artist_name', 'artist_title','artist_image')->get(); 
    //dd($artistList); 
    return view('website.listartist')->with(array('artistList'=>$artistList)); 
    //skljhkhkl 
} 

    public function getDonate(){ 

     return view('website.donate'); 
    } 

    public function getContact(){ 

     return view('website.contact'); 
    } 
} 

而且我Route.php看起來像這樣

<?php 

/* 
|-------------------------------------------------------------------------- 
| Application Routes 
|-------------------------------------------------------------------------- 
| 
| Here is where you can register all of the routes for an application. 
| It's a breeze. Simply tell Laravel the URIs it should respond to 
| and give it the controller to call when that URI is requested. 
| 
*/ 

Route::get('/', '[email protected]'); 
Route::controller('site', 'WebsiteController'); 

大多數鏈接比

www.domain正在等。 com/site/listartist

我得到錯誤爲

NotFoundHttpException在compiled.php線9361:控制器方法不 發現..

任何想法,我檢查過了,它看起來罰款

URLOFTheWebSite

感謝

+0

你有沒有在'Controller'中看到名爲'listartist'的函數? –

+0

@BasheerAhmed laravel如果它的一個get方法它解決了這個函數'getListartist()'相同的代碼在localhost btw工作正常 – Vikram

+0

糟糕我只是忘記了,但非網址工作。 url'http:// mad.ideleads.com/site/home' 'Class'App \ Http \ Controllers \ BaseController'找不到' –

回答

0

嘗試snake-case名代替方法。我不知道爲什麼,但camel-case不適用於由兩個單詞組成的方法。

public function get_some_name() {}; // www.example.com/anything/some-name 
public function get_somename() {}; // www.example.com/anything/somename 
//it doesn't seem to work with camel-case e.x getSomename(); www.example.com/anything/somename 
public function get_version() {}; //It will also work with camel-case 

希望它有幫助。

+0

我越來越困惑Bhai,你是說我應該把URL從'listartist'改成'list_artist',然後在我的控制器中我應該把函數改成'get_list_artist()'? – Vikram

+0

nop只是將其更改爲'get_listartist',其餘的應該像expencted一樣工作。 –

+0

函數名稱或url? – Vikram

相關問題