Browse AI Field GuideForum Podcast
All ThreadsLeaderboard
  1. Discussions

    1. Popular This Week
    2. Popular All Time
    3. Solved
    4. Unsolved
    5. No Replies Yet

mvww11's avatar

route:cache returns I'm using route closure. But I'm not!

Hello, folks! I'm trying to use php artisan route:cache on my shared hosting server, but it returns [LogicException] Unable to prepare route [api/user] for serialization. Uses Closure. I commented out the only route closures I'm using, but I still get the same error. Here my routes/web.php file. I'm nothing using route closures anymore! Am I wrong? Should I run some command

mvww11's avatar
mvww11's avatar ChristophH...8yrs agoLaravel
1
1
Last reply by ChristophHarms 8yrs ago
orj's avatar

Node must exists error in Nestedset

Im using kalnoy/nestedset package for nesting categories but there's an error when creating a new child category Here is thei first part of the error after submitting the create form (1/1) LogicException Node must exists. in NodeTrait.php (line 1181) Here is the code that i use for my Post categories model use Illuminate\Database\Eloquent\Model; use Kalnoy\Nestedset\NodeTrait

orj's avatar
orj's avatar wahidali4yrs agoLaravel
5
1
Last reply by wahidali 4yrs ago
PacoW's avatar

Relationship method must return an object of type Illuminate\Database\Eloquent\Relations\Relation

Hi all. I do know what this error message means: you forgot () somewhere. But I can't find it anywhere inside my code, and the stack trace doesn't show me where I'm wrong... LogicException in HasAttributes.php line 403: Relationship method must return an object of type Illuminate\Database\Eloquent\Relations\Relation It refers to a variable or function called "name" in

PacoW's avatar
PacoW's avatar Snapey9yrs agoLaravel
7
2
Last reply by Snapey 9yrs ago
Cryank's avatar

Can a model HasOne relation depends on attribute ?

Hi all, I am not sure if I on the right track, According to doc, Polymorphic relations allow a model to belong to more than one other model on a single association. I am wondering can a model has either A or B relation on a single association ? here is my case : User has one "StaffInfo" or "VisitorInfo" ( just for an example) depends on their user_type I wa

Cryank's avatar
Cryank's avatar vipin939yrs agoEloquent
7
1
Last reply by vipin93 9yrs ago
mtag's avatar

Route cache Error Help !

i got that error when i am trying command php artisan route:cache Route cache cleared! [LogicException] Unable to prepare route [api/user] for serialization. Uses Closure. I know no closure in my Web file and that it web.php #USERS ROUTES TO CONTROLLERS Route::get('/users','UsersMngController@index'); Route::get('/users/{user}/edit','UsersMngController@edit'); Route::put('/use

mtag's avatar
mtag's avatar mtag9yrs agoLaravel
3
1
Last reply by mtag 9yrs ago
mtag's avatar

ERROR IN route:cache

i got that error when i am trying command php artisan route:cache Route cache cleared! [LogicException] Unable to prepare route [api/user] for serialization. Uses Closure. Iknow no closure in my Web file and thats it #USERS ROUTES TO CONTROLLERS Route::get('/users','UsersMngController@index'); Route::get('/users/{user}/edit','UsersMngController@edit'); Route::put('/users/{user

mtag's avatar
mtag's avatar mtag9yrs agoCode Review
0
1
Niely's avatar

oauth-private.key does not exist or is not readable

Hi! So, I imported another project from Bitbucket and tried to launch it using 'php artisan serve', I always get this error: " [LogicException] Key path "file:///var/www/html/DesignViewer5/storage/oauth-private.key" does not exist or is not readable " I don't get this error when I make a project myself, I can't run any other command. I tried 'php artisan key

Niely's avatar
Niely's avatar Niely9yrs agoLaravel
1
1
Last reply by Niely 9yrs ago
jahid's avatar

relationship method

i am new at laravel 5.2 so hope you guys will help me. i am creating an application named BLOG. in this blog app i have created a relation between post and category method. who ever post a status it will show the category i have assigned manually form database. but i have made a field for create category where users can create category. but when i submit the category it shows L

jahid's avatar
jahid's avatar DmitriySem...9yrs agoLaravel
2
1
Last reply by DmitriySemenov 9yrs ago
stevgouws's avatar

Not even sure what to name what I want to do...

Say I have many clubs that all need to pay a yearly subscription, so will have several subscription records. I've set up my relationship: In Club.php public function subscriptionRecords() { return $this->hasMany('App\ClubSubscriptionRecord'); } But now I want to set up something where I can easily check if each club has paid their subscription in the current

stevgouws's avatar
stevgouws's avatar stevgouws9yrs agoLaravel
3
1
Last reply by stevgouws 9yrs ago
ahm750's avatar

route:cache returns error

When I use 'php artisan route:cache', it returns an error: Route cache cleared! [LogicException] Unable to prepare route [api/user] for serialization. Uses Closure.

ahm750's avatar
ahm750's avatar jeffdavis9yrs agoLaravel
4
1
Last reply by jeffdavis 9yrs ago
fbc's avatar

make:auth causes 'Unable to prepare route [api/user] for serialization. Uses Closure.'

I when I use make:auth in Laravel 5.3 and try to run 'php artisan route:cache' I get this error: [LogicException] Unable to prepare route [api/user] for serialization. Uses Closure. Did I do something wrong? Also 'php artisan route:list' is failing to show all my routes. I'm pretty sure the first problem is causing the later.

fbc's avatar
fbc's avatar fbc9yrs agoLaravel
2
1
Last reply by fbc 9yrs ago
ianmcqueen's avatar

Laravel Cashier: Creating new subscription on customer that already exists

I'm on Laravel 5.2, using Laravel Cashier to process and manage subscriptions to our platform. Here's what happened. A user's credit card expired and they forgot Stripe attempted the standard "3 retries" before totally failing All retries failed, and Stripe ends up deleting the sub_* subscription record permanently The user wants to resume their subscription The tro

ianmcqueen's avatar
ianmcqueen's avatar ianmcqueen9yrs agoLaravel
0
1
arslan2037's avatar

I am stuck in this error

I create a new Model, there is no relation in this Model file but i get this error, LogicException in Model.php line 2673: Relationship method must return an object of type Illuminate\Database\Eloquent\Relations\Relation

arslan2037's avatar
arslan2037's avatar bugsysha9yrs agoLaravel
16
1
Last reply by bugsysha 9yrs ago
KHAN's avatar

How to get the count of a hasMany relationship within the Model

Hey, Im trying to get the count of a hasMany relationship. In my scenario Event has many Reservations Controller $event = EventModel::find(1); return $event->rsvps()->count(); This works perfectly it returns the count for me. However i want to extract this and put it as a function within my Model class, so i can check whether the event is full. Model public function

KHAN's avatar
KHAN's avatar KHAN9yrs agoCode Review
2
1
Last reply by KHAN 9yrs ago
tbkinc's avatar

Adding a Function to a Model / Relationship method must return an object of type Relation

I am trying to add a function to my model that is not a relationship, scope, or mutator. Is this possible/advised? I have: class OrderLineItem extends Model { public function fill_backorder() { Log::debug('Fill backorder.'); $self = $this; $qty_to_fill = $self->QuantityNeeded; if($self->SkuDetails->QOH >= $qty_to_fill) {

tbkinc's avatar
tbkinc's avatar tbkinc10yrs agoEloquent
1
1
Last reply by tbkinc 10yrs ago
dstewart101's avatar

PHP Unit - Can't get an expected result with a date

Hi folks - I have what I thought was a straightforward test to write for a date: function testABetHasACreatedAtDate() { $this->assertEquals('2015-12-30 00:59:06', $this->bet->created_at()); } and there is the model I'm testing: public function created_at() { return $this->created_at; } I get this as the error: LogicException: Relationship m

dstewart101's avatar
dstewart101's avatar dstewart10...10yrs agoPHP
4
1
Last reply by dstewart101 10yrs ago
tylernathanreed's avatar

Chaining Multiple Belongs To Many Relationships

Consider the following Schema: users id ... roles id ... permissions id ... role_user role_id user_id ... permission_role permission_id role_id ... And the following Relationships: User.php public function roles() { return $this->belongsToMany(Role::class); } Role.php public function users() { return $this->bel

tylernathanreed's avatar
tylernathanreed's avatar bashy10yrs agoEloquent
7
1
Last reply by bashy 10yrs ago
giviz's avatar

Artisan --version Option in a Regular Command

Hi guys, I've tried to use an option called 'version' in a regular command, but I end up with an error : [LogicException] An option named "version" already exists. I've dig deeper into the error, and the problem is that '--version' is already used by laravel to provide it's version number: php artisan --version Laravel Framework version 5.0.33 Symfony\Component\Consol

giviz's avatar
giviz's avatar giviz10yrs agoLaravel
0
1
nathan-lochala's avatar

PHPunit: Form Ancestor Not Found

I have a simple form: <!--NEW FORM--> <form method="POST" action="http://192.168.114.139/family/search_results" accept-charset="UTF-8" id="admin-form"><input name="_token" type="hidden" value="7v2IhbTkiMRVyojJ8Vuv0dDdRqySzO18Z6gPWKP2"> <input class="gui-input&q

nathan-lochala's avatar
nathan-lochala's avatar absiddique...11yrs agoTesting
1
1
Last reply by absiddiqueLive 11yrs ago
BENderIsGr8te's avatar

I can't route cache with Clockwork

I am trying to setup my application so that I can route cache upon deployment. The problem I am running into with with Clockwork. I use Clockwork on my local machine during development, but by Default Clockwork doesn't run when the environment is set to Production, so while it "loads", it doesn't respond to any commands (or at least that's my understanding of it. Is t

BENderIsGr8te's avatar
BENderIsGr8te's avatar jekinney11yrs agoLaravel
1
1
Last reply by jekinney 11yrs ago
Ozan's avatar

Managing Mass User Settings

I did exactly the same things as @JeffreyWay did and I get this error. [LogicException] Relationship method must return an object of type Illuminate\Database\Eloquent\Relations\Relation

Ozan's avatar
Ozan's avatar Kryptonit311yrs agoLaravel
21
1
Last reply by Kryptonit3 11yrs ago
ryank30's avatar

Image file upload rules in Request

Hi, I have a form which takes input data as well as an image file. I have created a request called "AccountRequest" and I put some validation filters for "file". public function rules() { return [ 'first_name' => 'required|min:3', 'last_name' => 'required|min:3', 'email' => 'required|email|max:255', 'address' =>

ryank30's avatar
ryank30's avatar ryank3011yrs agoGeneral
4
1
Last reply by ryank30 11yrs ago
iMyque's avatar

Eloquent Dynamic Properties not fetching - L5

Hello Jeff, Thanks for this tutorial, It has made my sojourn into Laravel much more easier. I have an issue with Eloquent, When I try to access an attribute of the related User object from an Article object like this; $article = Article::findOrFail($id); $article->user->name; I get this error, what could be wrong?: LogicException in Model.php line 2641: Relationship meth

iMyque's avatar
iMyque's avatar deringer11yrs agoEloquent
3
1
Last reply by deringer 11yrs ago
sasafister's avatar

Resource for @ symbol

How to get @ symbol in front of username with resource? I don't want to write every single http request for simple CRUD thing? Route::resource('@{ime}', 'UsersController'); this returns error LogicException Route pattern "/@{ime}/{@{ime}}" cannot reference variable name "ime" more than once.

sasafister's avatar
sasafister's avatar sasafister11yrs agoGeneral
0
1
wonder95's avatar

How to avoid Slack notifications actually being sent during tests

In my continuing struggle to upgrade Slack functionality in Laravel 11 from the simple nathanheffley/laravel-slack-blocks to the much more complex core laravel/clack-communication-channel, I need to figure out how to keep notifications from actually being sent, because all my http requests are failing when running tests because there is no slack channel to connect to in CircleC

wonder95's avatar
wonder95's avatar puklipo1yr agoLaravel
2
3
Last reply by puklipo 1yr ago
montrealinthefall's avatar

return back(); not working for 1 route, but works perfectly for nearly identical route

I have 2 routes, one for canceling subscription, and one for resuming, and unless I am missing something, both routes are identical except for the names/functions/urls. When I cancel resume the subscription, I click the /resume url, it performs the function, and then returns back, and it's all so fast it seems like it never leaves the page, then it flashes the success message.

montrealinthefall's avatar
montrealinthefall's avatar montrealin...2yrs agoLaravel
1
1
Last reply by montrealinthefall 2yrs ago
mahmoudtrageh's avatar

Laravel 9 unable to handle this request Error

Hi I got this error when deploy laravel application to Apache Server Unable to handle this request this is my Laravel.log file outpout [2023-03-30 10:42:46] local.ERROR: Your configuration files are not serializable. {"exception":"[object] (LogicException(code: 0): Your configuration files are not serializable. at /var/www/html/ajman/vendor/laravel/framework/src/

mahmoudtrageh's avatar
mahmoudtrageh's avatar LaryAI3yrs agoLaravel
1
1
Last reply by LaryAI 3yrs ago
mohammadkhallaf's avatar

when run php artisan optimize i have this erroe

Unable to prepare route [confirm-password] for serialization. Another route has already been assigned name [password.confirm]. at C:\xampp\htdocs\optical\vendor\laravel\framework\src\Illuminate\Routing\AbstractRouteCollection.php:219 215▕ $route->name($this->generateRouteName()); 216▕ 217▕ $this->add($route); 218▕ } e

mohammadkhallaf's avatar
mohammadkhallaf's avatar mohammadkh...3yrs agoLaravel
9
1
Last reply by mohammadkhallaf 3yrs ago
mcadio's avatar

Files are not serializable

I pulled my changes to the server and ran php artisan config:cache and it cleared but gave me this message. I don't know how to fix it. Can someone please help me understand what this means? Your configuration files are not serializable. at vendor/laravel/framework/src/Illuminate/Foundation/Console/ConfigCacheCommand.php:71 67▕ require $configPath; 6

mcadio's avatar
mcadio's avatar thinkverse3yrs agoLaravel
16
1
Last reply by thinkverse 3yrs ago
SI-IC's avatar

Problem with telescope when using redis cache

Can anyone help me? I posted this bug to the github, but they addressed me to the forum. Telescope Version: 4.8.0 Laravel Version: 9.4.1 PHP Version: 8.1.3 Database Driver & Version: mysql 8.0.28 Description: I have installed laravel sail and telescope. When I use in my code something like $config = Cache::rememberForever('config', function () { return 'hello'; }); everythi

SI-IC's avatar
SI-IC's avatar SI-IC3yrs agoLaravel
10
1
Last reply by SI-IC 3yrs ago
devionti's avatar

Problem with optimiziation

So I am trying to optimize my application but it says it is using closure. I checked web.php and all the routes point to a controller Web.php Route::get('/',['as' => 'site.home', 'uses' => 'BlogController@index']); Route::get('contact', ['as'=>'site.contact', 'uses' => 'BlogController@contact']); Controller public function index() { if(Session::get('lo

devionti's avatar
devionti's avatar Aiden4635yrs agoLaravel
5
1
Last reply by Aiden463 5yrs ago
Garet's avatar

Cannot cache config, Your configuration files are not serializable

I have one Laravel project and when in production when I do: php artisan config:cache I get the following error: Your configuration files are not serializable I read that this is often down to callbacks being done in a configuration file, but I have double checked and there are no callbacks in my configuration files! The full error is below. It makes reference to ConfigCache

Garet's avatar
Garet's avatar Garet6yrs agoCode Review
6
7
Last reply by Garet 6yrs ago

Want us to email you occasionally with Laracasts news?

Nine out of ten doctors recommend Laracasts over competing brands. Come inside, see for yourself, and massively level up your development skills in the process.

Learn
BrowseSeriesCreatorSeriesLaravel PathLarabitsPlayground
Discuss
ForumPodcastSupport
Extras
Gift CertificatesApparelFAQiOS AppTerms
Social
X(Twitter)TikTokYoutube

© Laracasts 2026. All rights reserved. Yes, all of them. That means you, Todd.

Proudly hosted with Laravel Forge and DigitalOcean.

Want us to email you occasionally with Laracasts news?

Nine out of ten doctors recommend Laracasts over competing brands. Come inside, see for yourself, and massively level up your development skills in the process.

Learn
BrowseSeriesCreatorSeriesLaravel PathLarabitsPlayground
Discuss
ForumPodcastSupport
Extras
Gift CertificatesApparelFAQiOS AppTerms
Social
X(Twitter)TikTokYoutube

© Laracasts 2026. All rights reserved. Yes, all of them. That means you, Todd.

Proudly hosted with Laravel Forge and DigitalOcean.