1
votes

I get the following error

SQLSTATE[42S22]: Column not found: 1054 Unknown column '' in 'where clause' (SQL: select * from users where `` = 7pAJDfttBDr5tTJtkV0zQSE2QX1Zh8CFSycMaCg7yRmzHNyb5DAXATRp8gbs limit 1)

ActionsController.php

    <?php

    namespace App\Http\Controllers\Api;

    use Illuminate\Http\Request;
    use App\Http\Controllers\Controller;
    use App\Company;
    use App\User;
    use App\Company_User;
    use App\Company_Follower;
    use Auth;

    class ActionsController extends Controller
    {
        public function __construct()
        {
            return $this->middleware('auth:api');
        }

        public function follow_company(Company $company)
        {

            return response()->json(['test' => auth()->id()]);
        }

    }

Routes\Api.php

route::any('companies/{company}/follow','ActionsController@follow_company')
->name('api.companies.follow');

url : http://test.loc/api/companies/1/follow?api_token=7pAJDfttBDr5tTJtkV0zQSE2QX1Zh8CFSycMaCg7yRmzHNyb5DAXATRp8gbs

Post your query - B001ᛦ
Maybe the "" ommit token in query. As @B001ᛦ post query, ->toSql() - Bas
Looks like it might be an issue in your guards array inside config/auth.php . Can you show what the array element with the key of "api" looks like ? - Kirsty Wright
here is the api array 'api' => [ 'driver' => 'token', 'provider' => 'users', ], - Ahmed Barakat
there is no any queries just this lines but if i changed the the guard of auth to web it works like charm - Ahmed Barakat