2
I have a question here and I would like some help. I have a controller where you have to make a query in the Boxes table where you check whether the box is open or closed.
public function index(Request $request)
{
$caixas = DB::select('SELECT * FROM caixas INNER JOIN
users ON users.id = users.id JOIN caixas c ON c.data_abertura = c.data_abertura');
if( $caixas )
return view('vendas.index', compact('caixas'));
else
return view('vendas.caixa');
}
It is working, however when I soon with user 1 and open the box it opens and does the if
blz, if I dislodge and log in with user 2 it continues with the open box, does not identify that user 2 is with closed box.
Thank you.
That one
on
select has no sense. And where do you use user information in that query ? And why not use Eloquent to obtain bank information?– Isac
Hello Isac, I’m trying to do that when logging into the system in the PDV menu it check if the box is open or closed so entering in the if however I’m not able to validate it, because when I open the box with user 1 blz, Then I move and then user 2 checks that the user 2 is with closed box, would have an example of that with eloquent? Thank you
– Alexandre Oliveira
To use Eloquent and obtain the same information you must have the models and relationships constructed correctly. Where do you use the logged-in user information ? I don’t see this in this query. And how do you detect if you have the box open or closed ?
– Isac
Actually I do not know if the logged-in user will solve, plus what I need the system to do, would be a validation that when user1 log into the system to operate the box it identifies whether the box is open or not there would be a query in the status table for example, and in case there are more boxes like supermarket it identifies that the logged-in user would be open cashier or not. I’m sorry if I can’t explain it properly, thank you
– Alexandre Oliveira