2017-08-25 68 views
0

我使用laravl 5.2和以下是我的代碼Laravel:方法是在控制器中定義但它說沒有找到方法

我收到錯誤

ReflectionException在Route.php行280: 方法App \ Http \ Controllers \ Signup_controllers :: guestcheckout()不存在

我在做什麼錯? plz幫助

這是我route.php

Route::group(array('prefix' => 'signup'), function() 
{ 
    Route::resource('/register', '[email protected]'); 
    Route::resource('/guestcheckout', '[email protected]'); 
    Route::resource('/login', '[email protected]'); 
    Route::resource('/logout', '[email protected]'); 
    Route::resource('/ajaxCheckCustomerEmailExist', '[email protected]'); 
}); 

這是我的註冊控制器

<?php 

    namespace App\Http\Controllers; 
    use Illuminate\Http\Request; 
    use App\Http\Requests; 
    use App\Http\Controllers\Controller; 
    use Illuminate\Support\Facades\Input; 
    use Symfony\Component\HttpFoundation\File\UploadedFile; 
    use Symfony\Component\HttpFoundation\Session\Session1; 
    use Illuminate\Support\Facades\Validator; 
    use Illuminate\Support\Facades\Redirect; 
    use Image; 
    use Session; 
    use DB; 
    use Mail; 

    use App\Http\Models\Frm_mailing_list; 
    use App\Http\Models\Frm_contactus; 
    use App\Http\Models\Emailautoresponse; 
    use App\Http\Models\Adminemail; 
    use App\Http\Models\Emailsetting; 
    use App\Http\Models\Product_price; 

    class Signup_controllers extends Controller 
    { 
     public function index(Request $request) 
     { 

     } 
     public function register(Request $request) 
     { 
      include(public_path().'/app/Http/Controllers/action/register_controllers.php'); 
     } 
     public function login(Request $request) 
     { 
      include(public_path().'/app/Http/Controllers/action/login_controllers.php');  
     } 
     public function logout() 
     { 
      Session::flush(); 
      return Redirect::away(url('/login-registration'))->send(); 
     } 
     public function guestcheckout(Request $request) 
     { 
      include(public_path().'/app/Http/Controllers/action/guestcheckout_controllers.php');  
     } 

     public function ajaxCheckCustomerEmailExist(Request $request)  
     { 
      //Checked By Ranjit 
      $email=$request->email; 
      $customerData=array('email'=>$email); 
      $Customer=new Customer; 

      $resultCustomer=$Customer->getByAttributesQuery($customerData); 
      if($resultCustomer['recordCount']>0){ 
       echo "false"; 
      }else{ 
       echo "true"; 
      } 
     } 
    } 

當我嘗試調用guestcheckout它說沒有找到方法,即使我已經將它定義

回答

0

您正在使用資源控制器不正確。請參閱Laravel文件。

https://laravel.com/docs/5.4/controllers#resource-controllers

+1

1)這是一條評論。 2)是什麼讓你認爲控制器使用不當? –

+0

資源控制器只能分配一個控制器,而不是控制器內部的一個方法 'Route :: resource('photos','PhotoController');'' –

0

變化:

Route::resource('/guestcheckout', '[email protected]'); 

Route::post('/guestcheckout', '[email protected]'); 

和做其他途徑同樣的事情,與postget您的需求更換resource

Laravel資源路由通過一行代碼將典型的「CRUD」路由分配給一個 控制器。你這樣稱呼它: Route::resource('photos', 'PhotoController');

2
Route::get('/register', '[email protected]'); 

你包括控制器內的控制器和東西alsorts是不對您的代碼,會導致您的問題

我會考慮讀了解Laravel如何工作的文檔

相關問題