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

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -