eloquent - Laravel returning only single column -


in database have categories , sizes, have table match them called category_sizes looks like:

table fields screenshot

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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -