factory(App\Category::class, 10)->create()->each(function ($c) {
factory(App\Product::class, 25)->create()->each(function ($p) use ($c){
$p->categories()->attach($c);
factory(App\Photo::class, rand(1, 3))->create()->each(function ($f) use ($p){
$f->product_id = $p->id;
$f->save();
});
});
});
Product::with(['attributes' => function ($q) use ($ar_select_properties) {
$q->whereIn('id', $ar_select_properties);
}])->get();
$route = Route::get('/home', 'HomeController@index');
$route->name('home');
'SELECT name FROM table WHERE 1 = 1'
мы записываем его ввиде DB::table('table')->select('name')->where('1', '=', 1);