jeudi 16 mai 2019

SQLSTATE[42S22]: (SQL: select * from `categories` where `categories`.`departement_id` = 1 and `categories`.`departement_id` is not null)

I am trying to select all categories of a specific departement

namespace App\Http\Controllers;

use App\Models\Departement;

use App\Models\Categorie;

use Illuminate\Http\Request;

use Illuminate\Support\Facades\App;

use Illuminate\Support\Facades\DB;

class Test extends Controller { public function test(){

    $depts=Departement::find(1)->categories;

    foreach ($depts as $dept){

        echo $dept->name;

    }

    return view('test');

}

}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire