Laravel雄辩地分为两列

I'm pretty new to eloquent and laravel so I am having trouble pulling some information from the database. For starters i have an items table that looks like this

Id type quantity

1 fancy 1 2 prof 5 3 fun 6

I am trying to write something like this:

if fancy equals 0 do not display the button

I am having trouble figuring out how to access the two columns simultaneously so the code knows which type to look at it's quantity.

I'm assuming every type exists only once (otherwise your question doesn't make much sense to me). I'm also assuming you have a model called Type.

You can retrieve the model instance like this:

$fancy = Type::where('type', 'fancy')->first();

And then get the quantity like this:

if($fancy->quantity > 0){
    // display button
}

Or a bit shorter, use pluck to get a specific value from the first row:

$fancyQuantity = Type::where('type', 'fancy')->pluck('quantity');

If you need to do this check for multiple of your types I recommend you use lists to create an array that holds all types and all their quantities:

$quantities = Type::lists('quantity', 'type');


if(array_get($quantities, 'fancy', 0) > 0){
    // display fancy button
}
if(array_get($quantities, 'fun', 0) > 0){
    // display fun button
}

Well, your question seems to little confuse to me, but if i'm not getting your question wrongly you should consider to handle this requirement through Scope method under Eloquent model just like:

public function scopeIsFancy(){
    return (bool) self::where('quantity','=',0);
}

And for call scope method through Model:

if(!ModelName::isFancy())
 //do something if not fancy