Open FatihKoz opened 1 year ago
Hi, While working on the new admin interface with filament, I encountered the same problem. I haven't had time to try to solve it yet but I think it's because the pivot and the main field have the same name and the main field overrides the pivot, (the main field is probably null in your case). I also had this problem with values, the main field worth 500 so I get 500 even if the pivot isn't null
If you call FareService::getReconciledFaresForFlight
it should return the proper ones
Yes, my capacities are always null
in the main fare 'cause I define them at subfleet level... And I think this was (and still is) the proper way to define them.
What I am doing now is (as far as remember) instead of reading it through aircraft->subfleet->fare, I think I am reading it through pirep->fare directly, sorry I forgot how I fixed my solution, if you need I can find it though.
I'm looking into how I can get around this in a way that filaments supports... Looks like subfleet->pivot->capacity
works
If you have the pirep, that's the correct place to read it from because it's calculated and stored
I'm not sure it's only related to pireps. I have this issue with the subfleet <> fare
relationship. $subfleet->fare->capacity
gives me the capacity in the fares table and not the subfleet_fare pivot
Yeah you have to go through the pivot, that's just how Laravel works. You can maybe add an accessor on the model which will check the pivot table, but at that point it's the call to the service, which does all the calculations
yeah actually I was a bit lost because in the filament docs they say to use only the pivot attribute name https://filamentphp.com/docs/3.x/panels/resources/relation-managers#listing-with-pivot-attributes But I found a way to make it all work I think. It may be their docs that is not accurate more than our application that is buggy.
As the title says,
$pirep->aircraft->subfleet->fare
is not providing the capacity with the model, but it is provided within thepivot
Version 7.0.0-dev+230621.16a31d
To Reproduce Just check the attributes of any
$pirep->aircraft->subfleet->fare
or check below data outputExpected behavior capacity should be there (like it is provided in the pivot)
Additional context
If this will be new default, we can just close the issue :)