Waqar Ali
Waqar Ali

Reputation: 137

How to get variable from other sql table in laravel?

i have 2 table 1st. users 2nd rebeatlogs.

for users table

$amount = $request->amount;

$user = Auth::user()->amount;

in rebeatlogs (based on user_id) table i have "balance" column instead of "amount" column and is not using "auth" how i will build simillar variable for $amount and $user in case of rebeatlogs column which is not using auth.

complete code for explaination :

public function checkAmount(Request $request)
    {
        $amount = $request->amount;
        $met = $request->method_id;
        $method = ManualPayment::findOrFail($met);
        $charge = $method->method_fix + (($amount * $method->method_percent) /100);
        $hit = $charge + $amount;
        $user = Auth::user()->amount;

Upvotes: -1

Views: 46

Answers (1)

Lexxusss
Lexxusss

Reputation: 552

    $userId = Auth::user()->id;  
    $user = Rebeatlog::where('user_id', '=', $userId)
      ->first()
      ->balance;

Upvotes: 1

Related Questions