This is AdminController.php
:
<?php
namespace App\Http\Controllers;
use Response;
use Illuminate\Support\Facades\DB;
use App\Caption;
use App\Image;
use App\Http\Controllers\Controller;
class AdminController extends Controller
{
public function admin() {
$images = Image::paginate();
return view('admin',[ '$images' => $images]);
}
}
And this is admin.blade.php
:
@extends('template')
@section('title')
Admin Page
@endsection
@section('header')
@endsection
@section('main')
@if (Auth::check())
@foreach ($images as $image)
<p value=''></p>
<form action="image//delete" method="post">
<button type="submit">Delete caption</button>
</form>
<form action="image//approve" method="post">
<button type="submit">Accept image</button>
</form>
@endforeach
@else
<p>Login first</p>
@endif
@endsection
@section('footer')
@endsection
Why do I get the following error?
ErrorException in 408148d5409ae6eebf768dc5721bd0d1d9af48af.php line 9:
Undefined variable: images (View: /Users/sahandz/Documents/School/Singapore/CS3226/backend/resources/views/admin.blade.php)
$images
is clearly defined in my controller.
Thanks.
via Sandi