douh9817 2018-06-06 05:12
浏览 53

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

I am currently trying to use my Business model (Business.php) to login business users. For some reason it is using my Consumer model (Consumer.php)

How can I reference my Business model in my 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 [];
    }
}

I don't see where it is referencing the Consumer Model here but need it to reference the Business Model.

  • 写回答

0条回答 默认 最新

    报告相同问题?