I'm trying to make APIs using laravel. They are working fine on localhost but when I upload them to my server they give me error
405 Method Not Allowed
routes/api.php
<?php
use Illuminate\Http\Request;
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
Route::post('logout', 'API\LoginController@logout');
Route::resource('users', 'API\UserAPIController');
Controllers\API\LoginController.php
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\User;
use App\Http\Controllers\API\APIBaseController as APIBaseController;
use DB;
use Validator;
use Hash;
class LoginController extends APIBaseController
{
public function logout(Request $request)
{
$user = User::find($user_id);
if (is_null($user)) {
return $this->sendError('User not found.');
}
User::where('id', $user->id)
->update([
'imei_no'=>'',
'device_id'=>''
]);
return $this->sendResponseArray($user_id, 'User successfully logout.');
}
}
Postman Screenshot (Server Run) Where error is showing
Postman Screenshot (Localhost Run) Successfully executed
I have already tried many answer posted on Stackoverflow but didn't find any solution
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire