Some PHP version or configuration were causing this error.
On app.blade.php of local branch, I could use "$usedItems ? :"
even if $usedItems were null, but I had to check an "isset" to the production.
On HomecController, I had to change the "object" parameter of getUsername
to "\Illuminate\Database\Eloquent\Collection" to make it work.
I took the chance to just show the number of itens in use
if it were greater than 0.
It was necessary to keep refreshing the page to
check if an item was returned when we did not
want to be alerted. So, now, the page refresh
itself every 2 minutes (while I do not know how
to use Laravel broadcasting) and the title shows
the number of items in use (including when used
by you).
The language were set only on session. But now it is
stored with user profile, on DB.
It is important as now I can send alert e-mails to each
user on their own languages and not the activer
user language.
Also, wherever the user logs out and logs in again,
it will see the same site locale.
The TakeController was manually sending the email message
as well as dealing with item return, so I moved the email message
to it's own listener, I created an event for it and moved the
return part to the item model.
When we had no items showing on home page, it were just blank.
Turns out that the @empty call that shows the default message
were appearing just when it had no items on a product, instead
of no items at all.
Fixed it moving the paragraph to the right place.
On email body, it usually appeared as the button to the website
would take directly an action, so the text was changed to make
sure the user will understand he is only going to access
the website.
The user can only open their own products.
If the user tried to open a product that belongs to
other person, the site were returning an error message.
Now it just go back to the last page.
I had included item_id and user_id as primary keys to avoid duplications
but the command line to attach I am using does not duplicate.
Not only that, I got an error during migration of Multiple primary keys.