“Array bersarang di Laravel” Kode Jawaban

Laravel mengembalikan array satu dimensi

    $catcount    = 2;
    $parents_ids = [];
    for ($i = 0; $i < $catcount; $i++) {
        $parents_ids[] = $userCategory[$i];
    }
    $subCats = Category::whereIn('parent_id', $parents_ids)->pluck('id');
Indian Gooner

Array bersarang di Laravel

class MenuController {
    public function lisItem($category_name, $product_name) {
        $category = Category::where('name', $category_name)->first(['id']);
        $product = Product::where('category_id', $category->id)->where('name', $product_name')->first();
    }
}

Route::get('/{category}/{item}', ['as' => 'named.route' , 'uses' => 'MenuController@listItem']);

// to get the actual linke
route('named.route', ['category' => $category->id, 'item' => $item->id]);
Funky Dev

Jawaban yang mirip dengan “Array bersarang di Laravel”

Pertanyaan yang mirip dengan “Array bersarang di Laravel”

Lebih banyak jawaban terkait untuk “Array bersarang di Laravel” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya