eloquent - Laravel returning only single column -
in database have categories , sizes, have table match them called category_sizes looks like:
i want array size_id
category_id = 4
did:
$catsizes = categorysize::where('category_id', 4)->value('size_id'); return($catsizes);
but returns 1 result only. how can array size_ids can use later in where_in
statement.
i tried pluck gives 1 row.
$catsizes = categorysize::where('category_id', 4)->pluck('size_id'); dd($catsizes);
my categoysize model
<?php namespace app; use illuminate\database\eloquent\model; class categorysize extends model { protected $table = 'category_sizes'; }
try this:
db::table('category_sizes')->where('category_id', 4)->get('size_id');
or:
db::table('category_sizes')->select('size_id')->where('category_id', 4)->get();
Comments
Post a Comment