我正在使用laravel 5.2,以下是我的代码
我收到错误
Route.php第280行中的ReflectionException: 方法App \ Http \ Controllers \ Signup_controllers :: guestcheckout()不存在
我做错了什么?请帮忙
这是我的route.php
Route::group(array('prefix' => 'signup'), function()
{
Route::resource('/register', 'Signup_controllers@register');
Route::resource('/guestcheckout', 'Signup_controllers@guestcheckout');
Route::resource('/login', 'Signup_controllers@login');
Route::resource('/logout', 'Signup_controllers@logout');
Route::resource('/ajaxCheckCustomerEmailExist', 'Signup_controllers@ajaxCheckCustomerEmailExist');
});
这是我的注册控制器
<?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 :(得分:2)
Route::get('/register', 'Signup_controllers@register');
你在控制器中包含了控制器,而且你的代码中的各种错误会导致你出现问题
我会考虑阅读文档以了解Laravel的工作原理
答案 1 :(得分:0)
您错误地使用了资源控制器。参见Laravel Documention。
https://laravel.com/docs/5.4/controllers#resource-controllers
答案 2 :(得分:0)
变化:
Route::resource('/guestcheckout', 'Signup_controllers@guestcheckout');
到
Route::post('/guestcheckout', 'Signup_controllers@guestcheckout');
并对其他路线执行相同操作,将resource
替换为post
或get
以满足您的需求
Laravel资源路由将典型的“CRUD”路由分配给a 控制器只有一行代码。你这样称呼它:
Route::resource('photos', 'PhotoController');