'Target class [App\Http\Controllers\User] does not exist
I'm creating a page which can edit the filename, artist name and album name of the uploaded song. Currently the error states as
Target class [App\Http\Controllers\User] does not exist
web.php
use App\Http\Controllers\UploadController;
Route::post('/updatesongs/{id}', [UploadController::class,'update']);
UploadController.php
public function update(Request $request,User $id)
{
$songname = $request->input('song_title');
$songartist = $request->input('song_artist');
$songalbum = $request->input('song_album');
DB::update('update music_uploads set filename = ?, artistname = ?, albumname = ? where id =?', [$songname, $songartist, $songalbum,$id]);
echo "Updated successfully <br>";
echo '<a href="/ngsongs">Click here to return</a>';
}
Solutions I've tried
RouteServiceProvider.php
protected $namespace = 'App\\Http\\Controllers';
uncommenting this line doesn't solve the problem
- clean the cache
php artisan route:cachedoesn't work
Any other solutions or is my code wrong?
Solution 1:[1]
we can create a controller Artisan command:
php artisan make:controller QuizzStatusController
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
