Hello, laravel throw me:
Call to a member function domain() on a non-object
view:
<article>
<header>
<h2><a href="{{ route('articles.show', [$article]) }}">{{{ $article->title }}}</a></h2>
<a href="{{ route('articles.show', [$article]) }}"><img src="{{ $article->thumbnail_url }}" alt="{{{ $article->title }}}"></a>
</header>
<div class="content">
{!! $article->shortContent !!}
<footer>
<a href="{{ route('articles.show', [$article]) }}" class="read-more">Czytaj dalej →</a>
</footer>
</div>
</article>
routes:
$router->get('/', ['uses' => 'ArticlesController@index', 'as' => 'articles.index']);
// $router->get('/c/{category}', ['uses' => 'CategoriesController@show', 'as' => 'categories.show']);
$router->get('/{article}', ['uses' => 'ArticlesController@show', 'as' => 'articles.show']);
What's wrong?
I had the same error. Do composer update and make sure your app directory is up to date with the latest changes in the upstream Laravel git repository
I have newest files and problem is still there. Any other sugestions?
For me the error was that I should use namespaces for the controllers in the helpers. The following gives me the weird error (Call to a member function domain() on a non-object).
action("HomeController@showWelcome")
Where by adding the namespace it started working. The error is not really helpful.
action("App\Http\Controllers\HomeController@showWelcome")
With the newly released version of Laravel 5, I experienced the exact opposite.
return redirect()->action('App\Http\Controllers\HomeController@index');
caused the domain() on null, where as the following:
return redirect()->action('HomeController@index');
worked fine. Quite misleading as the documentation specifies using the first approach... O_o
Update: So - it seems action() returns the url routing to this particular method. I was attempting to use it without an existing route to a method which works with neither of the approaches above. For good reason I guess. In my case I should probably just call the function specifically rather than using the routing system as a way to control my program flow.
In any case, my previous statement stands. Of the two methods, the latter works for me IF you've already defined a route for that particular method. Otherwise, both methods will return the null domain function thingy ka-jigger.
I had the same issue when misspelling my controller name in action()
.
Example:
action('UserController@update', $user->id) // causes the error.
action('UsersController@update', $user->id) // It should be this. (notice the s in Users)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community