vendredi 1 mars 2019

I get a 404 error when he should not :laravel

I developed an API and I have a problem whith this page I add it in my route and always I get a 404 error I don't know why

this my controller:

class InsertPPictureController extends Controller
{
    public function profilepicture (Request $request)
    {
        $input = $request->all();

        $validator =    Validator::make($input, [
            'id_user'=> 'required',
            'picture'=> 'image|nullable|max:1999'
        ] );

        $user = User::findOrFail($request->id);
        $user_id = $request->id ;

        if($request->hasFile('picture')){
            // Get filename with the extension
            $filenameWithExt = $request->file('picture')->getClientOriginalName();
            // Get just filename
            $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME);
            // Get just ext
            $extension = $request->file('picture')->getClientOriginalExtension();
            // Filename to store
            $fileNameToStore= $user_id.'.'.$extension;
            // Upload Image
            $path = $request->file('picture')->storeAs('public/profilepic', $fileNameToStore);
            $user->pic_path = $fileNameToStore ;
            $user->update();


        } else {
            $fileNameToStore = 'noimage';
        }

        return response()->json(' Success : User updated with success ',200);
    }
}

and this is my api.php

Route::group(['middleware' => ['jwt.verify']], function() {
    Route::get('logout', 'AuthController@logout');
    Route::post('postcreditscards', 'CreditsCardsController@stockcards');
    Route::get('getcreditscards', 'CreditsCardsController@index');
    Route::get('getmybalance', 'MyBalanceController@index');
    Route::get('getuserdata', 'AuthController@getuser');
    Route::post('sendMoneyTransaction', 'MyBalanceController@updatebalance');
    Route::post('isvalidnumber', 'AuthController@validnumber');
   Route::post('updateuser', 'AuthController@updateuser');
     Route::post('insertprofilepicture','InsertPPictureController@profilepicture');

});

all the pages work fine only this page don't work Route::post('insertprofilepicture','InsertPPictureController@profilepicture');



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire