Support the ongoing development of Laravel.io →
Eloquent Database Laravel

Hello,

i try to explain my Problem.

I have 2 Tables in relationship

shootingbooks and shootingranges

in table shootingranges.totalplaces you can found a Number ex.20 That means, the total amount of Places in the shootingrang

in my table shootingbook i have stored, all entry from users.

With end = Null i can select all occupied entrys. on field place i can found the actuall place in use.

I tried to make a method

$totalplaces = Shootingrange::where('id' ,7)->first()->totalplaces; $occupiedplaces = Shootingbook::select('bahn')->where('shootingrange_id', 7)->whereNULL('ende')->get(); $op = $occupiedplaces->toArray();

first i get the max number of totalplaces second i get the occupiedplaces

with range i can get all Numbers from 1 to X

dd(range(1,$totalplaces ));

BUT, how can i become all free places?

Is there a eloquent method??

Last updated 2 years ago.
0

wrong question?? :-)

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Matthias matze1708 Joined 22 Jul 2020

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.