Question

I'm trying to do this

$this->current_user->company->routes

And am expecting to get a list of routes based on the currently logged in users company.

This is the error that I get

Symfony \ Component \ Debug \ Exception \ FatalErrorException

Call to undefined method Illuminate\Support\Facades\Route::newQuery()

I know I'm getting the correct info from both of the following

$this->current_user

and

$this->current_user->company

Here is my company model

<?php

class Company extends Eloquent
{
protected $guarded = array(
    'id',
    'created_at',
    'updated_at',
);

public static function getDropDownArray()
{
    $return = array();
    $companies = Company::all();

    foreach($companies as &$company)
    {
        $return[$company->id] = $company->title;
    }

    return $return;
}

public function routes()
{
    return $this->hasMany('Route');
}

public function users()
{
    return $this->hasMany('User');
}

public function locations()
{
    return $this->hasMany('Location');
}

public function publications()
{
    return $this->hasMany('Publication');
}

public function racks()
{
    return $this->hasMany('Rack');
}
}
Was it helpful?

Solution

You must have named one of your Eloquent classes Route and this is conflicting with Laravel's Route alias.

So you have 2 options:

1) Use namespaces

2) Rename your class

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top