T
T
th1s2016-03-21 19:33:11
Laravel
th1s, 2016-03-21 19:33:11

Undefined variable what's wrong?

Gives an error Undefined variable: pays (View: /www/resources/views/admin/index.blade.php)
Controller

public function pays() {
        $pays = DB::table('pay')
            ->select('pay.*', 'users.username')
            ->join('users', 'pay.uid', '=', 'users.id')
            ->where('uid', '>', '0')
            ->orderBy('buy_at', 'desc')
            ->get(); 		
    	return view('admin.index', compact('pays'));
    }

Iterating in index.php
@forelse($pays as $pay)
                        <tr>
                          <td><a target="_blank" href=""></a></td>
                          <td></td>
                        </tr>
                        @empty
                            <center><h1 style="color: #33BDA6;"> нет!</h1></center>
                        @endforelse

What is wrong, please tell me. If possible with an example

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Karabanov, 2016-03-21
@karabanov

This is not an error, but a warning. Set (perdivide) the $pays variable .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question