php - Laravel access classes without namespace in views -
usually, laravel out of box able access default "user" model without prefixing namespace routes, within view, so:
user::find(1);
however, if create model, example - "business", in order access in views need following:
app\business::find(1);
is there way "use" classes globally in views, works user class?
thanks in advance.
edit: works if following in blade.php file, example:
@extends('layouts.main') @section('content') <?php use app\business; ?> {{ business::find(1)->name }} @stop
but seems not-so-clean way it. or wrong , acceptable?
p.s - using laravel 5.1
not idea eloquent models technically can service injection since laravel 5.1. again should better off doing in controller , passing data in.
something along lines of:
@inject('business', 'app\business') @section('content') {{ $business->find(1)->name }} @stop
Comments
Post a Comment