Reputation: 2314
namespace App\Http\Controllers;
use App\Image;
use Illuminate\Http\Request;
/**
* @property \Illuminate\Database\Eloquent\Model|null|static about
* @property \Illuminate\Database\Eloquent\Collection|static[] images
*/
class MediaController extends Controller
{
/**
* MediaController constructor.
*/
public function __construct()
{
$this->images = Image::all();
}
/**
* Generate the Media page.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$images = $this->images; //Is there a way to bypass this
return view('media', compact('images'));
}
}
Quite a simple one probably, is there a way to directly reference $this->images
from within the compact method here? I'd like to access the this context directly without needlessly assigning a variable.
Upvotes: 1
Views: 129