added relationship for company and user

This commit is contained in:
jack
2018-05-26 09:37:56 +08:00
parent ba827bf27d
commit ff4e7764d5
3 changed files with 13 additions and 0 deletions
+5
View File
@@ -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');
}
}
+3
View File
@@ -100,6 +100,9 @@ class AuthController extends Controller
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
return response()->json(['success' => true, 'token' => $userToken,
+5
View File
@@ -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');
}
}