dimanche 2 décembre 2018

What is wrong with my route or controller for listing resources belonging to a given language identifier?

I am trying (and failing!) to generate a list of factsheets from the database that have been tagged according to language (English or Vietnamese). I have a route in which the variable can be either "en" or "vn" being passed to the index function in my controller

Route::get('/pest/{id}', 'api\FactsheetsController@index');

My controller is currently as...

namespace App\Http\Controllers\Api;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;

class FactsheetsController extends Controller
{
    public function index($lang)
    {

      $factsheets = DB::table("factsheetcontents as fsc")
        ->where('fsc.lang',$lang)
        ->select('fsc.title', 'fsc.id', 'fsc.shortimg')
        ->get();
      return $factsheets;    
    }

I receive an empty response ([]) for my efforts. What am I doing wrong here?

Thanks, Tom



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire