Anonymous shooter
Anonymous shooter

Reputation: 173

laravel fetch query skip data with column if condition

here is a query for fetch data from DB

 $subcatgeory = DB::table('subategories')->where('category_id',$item->id)->get();

in a subcategory, there is a column name for subcategory_En values are look like this

subcategory_En
sample data
sample data 2
unassign

i want to skip when the subcategory_En column value is unassign and fetch other data

so I try this query

$subcatgeory = DB::table('subategories')->where('category_id',$item->id)->skip('subcategory_En','unassign')->get();

this query is not working how can I fetch data and skip with column values?

Upvotes: 0

Views: 532

Answers (1)

Nortol
Nortol

Reputation: 449

Just do a second where clause.

$subcatgeory = DB::table('subategories')->where('category_id',$item->id)->where('subcategory_En', '!=', 'unassign')->get();

Skip is for limits and offsets. https://laravel.com/docs/8.x/queries#limit-and-offset

Upvotes: 2

Related Questions