2017-08-19 98 views
0

我有Laravel問題,becouse它沒有找到我的路線: 看錯誤:Laravel:方法不存在

(1/1) BadMethodCallException 
Method [sendEmail] does not exist. 

我的路線 「web.php」:

Route::get('/', function() { 
    return view('index'); 
}); 

Route::get('/studio', '[email protected]'); 
Route::get('/studio/contratos', '[email protected]'); 
Route::get('/studio/agenda', '[email protected]'); 
Route::get('/studio/clientes', '[email protected]'); 
Route::get('/studio/ensaios', '[email protected]'); 

Route::get('/home', '[email protected]')->name('home'); 
Route::get('/email/{id}', '[email protected]'); 

我控制器「UserController.php」:

<?php 

namespace App\Http\Controllers; 

use Mail; 
use App\User; 
use Illuminate\Http\Request; 
use App\Http\Controllers\Controller; 

class UserController extends Controller 
{ 
    public function sendEmail(Request $request, $id) 
    { 
     $user = User::findOrFail($id); 

     Mail::send('emails.reminder', ['user' => $user], function ($m) use ($user) { 
      $m->from('[email protected]', 'a Your Application'); 

      $m->to($user->email, $user->name)->subject('Your Reminder!'); 
     }); 
    } 
} 

一個奇怪的事情是,它工作在本地服務器上,但是當我把它上傳我ñ直播服務器,我有這樣的錯誤://

謝謝你們


錯誤?圖片:

Image error

+0

你能告訴我們從您正在訪問該路由的代碼? –

+0

從URL訪問 - >'www.photobooker.com.br/email/1' 我有一個ID爲1的用戶 – Hermus

+0

這似乎沒關係。你確定你在現場環境中推動了代碼嗎? –

回答

0

試試這個

<?php 

namespace App\Http\Controllers; 

use Mail; 
use App\User; 
use Illuminate\Http\Request; 
use App\Http\Controllers\Controller; 

class UserController extends Controller 
{ 
    public function sendEmail($id) 
    { 
     $user = User::findOrFail($id); 

     Mail::send('emails.reminder', ['user' => $user], function ($m) use ($user) { 
      $m->from('[email protected]', 'a Your Application'); 

      $m->to($user->email, $user->name)->subject('Your Reminder!'); 
     }); 
    } 
} 
+0

仍然是相同的錯誤:/ – Hermus

+0

我編輯了我的問題,添加圖像錯誤 – Hermus

-1

解決,我跑這個命令:

rm -rf vendor/laravel 

然後:

composer update 

我認爲這是一個錯誤類型的:///

謝謝你們