Tell me what I'm doing wrong. Here is the code that, if I insert directly into routes.php
routes.php Route::get('dashboard', 'DashboardController@index'); Route::get('wallets', 'WalletsController@index'); Route::post('addwallet', function(){ //принимаем данные от пользлвателя $wallet = Request::input('wallet', '+11111111111'); $query = DB::table('wallets')->insert( ['wallet' => $wallet]); }); then it works, and if I insert it into the class method, it does not work. I call the route like this: Route::get('addwallet', 'WalletsController@add');
namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Http\Requests; use DB; use Response; class WalletsController extends Controller { public function index(){ $wallets = DB::select('select * from wallets LIMIT 20'); return view('wallets.index', ['wallets' => $wallets]); } public function add(){ //принимаем данные от пользлвателя $wallet = Request::input('wallet', '+11111111111'); $query = DB::table('wallets')->insert( ['wallet' => $wallet]); } Here is the error that the console displays:
500 Internal Server Error 159ms jquery-....min.js (строка 5) "NetworkError: 500 Internal Server Error - http://exchanger.local/orders/laravel/public/addwallet"
public function add(Request $request){ //принимаем данные от пользователя $wallet = $request->input('wallet', '+11111111111'); $query = DB::table('wallets')->insert( ['wallet' => $wallet ]);public function add(Request $request){ //принимаем данные от пользователя $wallet = $request->input('wallet', '+11111111111'); $query = DB::table('wallets')->insert( ['wallet' => $wallet ]);- rodgers