Tuesday, February 28, 2017

How to pass variable from URL to DBcontroller

I'm new in Laravel and I tried this:

Router

Route::get('productdetails/{id}', function($id){
'ProductDetailsController@productdetails' .$id;

});

ProductDetailsController

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use DB;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class ProductDetailsController extends Controller
{
    public function inventory(){
    $inventory = DB::select('select * FROM inventory WHERE barcode = ?', [$id]);;
    return view('productdetails',['inventory'=>$inventory]);
    }
}

and I got:

NotFoundHttpException in RouteCollection.php line 161:




via Feralheart

Advertisement