I have two nearly identical methods in one controller (I did this for testing purposes). One is called "update", The other is called "store_images". The only difference is the method name. "update" normally has many other things going on, but in an effort to troubleshoot, I striped it down do one thing.
public function update(Request $request, Preplan $preplan)
{
$preplan->syncFromMediaLibraryRequest($request->images)
->toMediaCollection('buildings');
return redirect()->route('preplans.index');
}
public function store_images(Request $request, Preplan $preplan)
{
$preplan->syncFromMediaLibraryRequest($request->images)
->toMediaCollection('buildings');
return redirect()->route('preplans.index');
}
I am using Spatie Media Library Pro to upload images and this is the code to do that. The "store_images" method works just fine. But the "update" method returns:
invalid uuid
The routes use identical route types:
Route::get('/preplans/edit/{preplan}', [PreplanController::class, 'edit'])->name('preplans.edit');
Route::post('/preplans/edit/{preplans}', [PreplanController::class, 'update'])->name('preplans.update');
Route::get('/preplans/images/{preplan}', [PreplanController::class, 'upload_images'])->name('preplans.upload_images');
Route::post('/preplans/images/{preplan}', [PreplanController::class, 'store_images'])->name('preplans.store_images');
I have rebooted the server. I have done the following commands, all with no change:
php artisan config:clear
php artisan route:clear
php artisan view:clear
php artisan event:clear
php artisan cache:clear
php artisan optimize:clear
At first, I thought it was a Spatie Component issue, but having narrowed it down to two identical methods, with one working and the other not, it is clearly a Laravel issue.
I figure something must be cached somewhere or stored in memory, but I cannot figure it out. I even have the same behavior on TWO different servers (granted, I just made a copy of everything and moved it to a new server).
What am I missing?