Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hey i want to write a query that will check for balance when you click login and it will show a message that has your balance but if you dont have a balance it will allow you to login in laravel .Below is what i have tried.the list of balance is in another table called defaulters.

What I have tried:

protected function validateLogin(Request $request)
 {
     // "SELECT * from defaulters where myPIN => '$myPIN'"
     // union
     $defaulters = Defaulters_Reg::select('Debt_amount')->where('myPIN',$id)->get();
     $request->validate([
         'myPIN' => 'required|myPIN',
         'Debt_amount' => 'required|string'
         if ($validateLogin->fails())
         {
             return Redirect::to ('login')
         }
     ])

     $request->validate([
         $this->username() => 'required|string',
         'password' => 'required|string',
     ]);
 }
Posted
Updated 1-May-19 21:27pm
v3
Comments
Christian Graus 2-May-19 1:13am    
A syntax checker online said this code is valid. Where is the error?
harristars 2-May-19 2:03am    
syntax error, unexpected 'if' (T_IF), expecting ']'

1 solution

You've put your if statement inside of the $request->validate code rather than outside. According to the Laravel documentation you should instead be using the return value of the method:
PHP
$validateLogin = $request->validate([ .. ]);

if ($validateLogin->fails()) {
  ..
}
 
Share this answer
 
Comments
harristars 2-May-19 21:27pm    
I want it to check if mypin has balance from a table called default ers. So if my has balance it show you the balance and prevent you from logining in.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900