diff --git a/app/Company.php b/app/Company.php index af4bf8d..ee6bb6c 100644 --- a/app/Company.php +++ b/app/Company.php @@ -9,4 +9,9 @@ class Company extends Model // protected $fillable = ['company_profile', 'reg_cert', 'company_name', 'registration_no', 'tax_no', 'tel_no', 'fax', 'address', 'city', 'postcode', 'state', 'country', 'contact_person']; //protected $guarded = []; + + public function user() + { + return $this->belongsTo('App\User'); + } } diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 48d0639..2707ce1 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -99,6 +99,9 @@ class AuthController extends Controller if (!$userToken=JWTAuth::fromUser($check_user)) { return response()->json(['error' => 'invalid_credentials'], 401); } + + // TODO : Create company for user + $expiration = JWTAuth::setToken($userToken)->getPayload()->get('exp'); // all good so return the token diff --git a/app/User.php b/app/User.php index e82ca32..a5bb95e 100644 --- a/app/User.php +++ b/app/User.php @@ -54,4 +54,9 @@ class User extends Authenticatable implements JWTSubject return $this->hasOne('App\UserVerification', 'user_id'); } + public function company() + { + return $this->hasOne('App\Company'); + } + }