如何引用控制器laravel的特定模型

时间:2018-06-06 05:12:18

标签: php laravel rest login

我目前正在尝试使用我的商业模式(Business.php)来登录商业用户。由于某种原因,它使用我的消费者模型(Consumer.php

如何在BusinessAuthController.php

中引用我的商业模式

BusinessAuthController.php

namespace App\Http\Controllers;

use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\Controller;
use App\Business;


class businessAuthController extends Controller
{
    public function login()
    {
        $credentials = request(['email', 'password']);

        if (! $token = auth()->attempt($credentials)) {
           return response()->json(['error' => 'Unauthorized'], 401);
        }

        return $this->respondWithToken($token);
   }
}

Business.php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Business extends Authenticatable implements JWTSubject//Model
{
    use Notifiable;
    protected $table = 'businesses';
    protected $primaryKey = 'bus_id';

    protected $fillable = [ 'bus_id', 'bus_name', 'bus_address', 'bus_city', 'bus_prov', 'bus_postal', 'bus_phone', 'email', 'password', 'cashback_percent', 'bus_cover_photo', 'bus_profile_pic'];

    protected $hidden = [
       'password', 'remember_token',
    ];

    public function getJWTIdentifier()
    {
        return $this->getKey();
    }

    /**
    * Return a key value array, containing any custom claims to be added to the JWT.
    *
    * @return array
    */
    public function getJWTCustomClaims()
    {
        return [];
    }
}

我不知道它在哪里引用消费者模型,但需要它来引用商业模式。

0 个答案:

没有答案