diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 3dac0f2..3ac2596 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -159,6 +159,10 @@ class AuthController extends Controller return response()->json(['success'=> true, 'message'=> 'Profile updated.'], 200); } + public function show() + { + return response()->json(['user' => Auth::user()]); + } /** @@ -294,4 +298,6 @@ class AuthController extends Controller 'success' => false, 'data'=> ['message'=> 'Invalid token or email or expired code'] ]); } -} \ No newline at end of file +} + + diff --git a/app/Http/Controllers/CompanyController.php b/app/Http/Controllers/CompanyController.php index fc49076..b522c5b 100644 --- a/app/Http/Controllers/CompanyController.php +++ b/app/Http/Controllers/CompanyController.php @@ -55,6 +55,11 @@ class CompanyController extends Controller return response()->json(['success'=> true, 'message'=>'Company created successfully'],200); } + public function company() + { + return response()->json(['user' => Auth::user()]); + } + public function companyProfile(Request $request) { $company = Company::where("user_id", Auth::user()->id)->first(); diff --git a/public/home.html b/public/home.html index 99888ce..bbddbe1 100644 --- a/public/home.html +++ b/public/home.html @@ -282,21 +282,12 @@
- +
- +
-
- -
-
- -
-
- -
- + @@ -1295,7 +1286,45 @@ document.getElementById("branchText7").value = document.getElementById(type).value.textContent = "Populate Contact Person"; document.getElementById("branchText8").value = document.getElementById(type).value.textContent = "Populate Contact Person No"; } - + + +$.ajax({ + type: 'GET', + headers:{"Authorization": "Bearer " + localStorage.getItem('token')}, + url : "api/user", + contentType : "application/json", + dataType : "json", + async : false, + success : function(data) { + console.log('success'); + $('#user-name').html(data.user.name); + $('#user-phone').html(data.user.phone); + +} + + }); + +$.ajax({ + type: 'GET', + headers:{"Authorization": "Bearer " + localStorage.getItem('token')}, + url : "api/company", + contentType : "application/json", + dataType : "json", + async : false, + success : function(data) { + console.log('success'); + $('#company-name').html(data.company.name); + + +} + + }); + + + + + + diff --git a/public/images/avatar.png b/public/images/avatar.png new file mode 100644 index 0000000..c4f8f01 Binary files /dev/null and b/public/images/avatar.png differ diff --git a/public/profile-first-setup.html b/public/profile-first-setup.html index 0e99231..fe35e05 100644 --- a/public/profile-first-setup.html +++ b/public/profile-first-setup.html @@ -28,18 +28,7 @@
-
-
-
- - -
- -
-
+
diff --git a/routes/api.php b/routes/api.php index 94490cc..ded2b62 100644 --- a/routes/api.php +++ b/routes/api.php @@ -33,6 +33,7 @@ Route::post('verify-phone', 'AuthController@verifyPhone'); Route::group(['middleware' => ['jwt.auth']], function() { Route::get('logout', 'AuthController@logout'); Route::patch('user', 'AuthController@updateUser'); + Route::get('user', 'AuthController@show'); Route::get('test', function(Request $request){ return response()->json(['user'=> $request->user()]); }); @@ -46,8 +47,10 @@ Route::group(['middleware' => ['jwt.auth']], function() { /* Company */ + Route::get('/company', 'CompanyController@company'); Route::patch('/company', 'CompanyController@update'); //update company information Route::post('/company/company_profile/', 'CompanyController@companyProfile');//upload company profile picture Route::post('/company/reg_cert/', 'CompanyController@regCert'); //upload registration certificaate + Route::get('/delete/{id}', 'CompanyController@deletePost'); }); diff --git a/routes/web.php b/routes/web.php index 95cfefa..c37e5bf 100644 --- a/routes/web.php +++ b/routes/web.php @@ -25,3 +25,7 @@ //Route::post('login', 'AuthController@login'); Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.request'); Route::post('password/reset', 'Auth\ResetPasswordController@postReset')->name('password.reset'); +Route::patch('/company', 'CompanyController@update'); //update company information +Route::post('/company/company_profile/', 'CompanyController@companyProfile');//upload company profile picture +Route::post('/company/reg_cert/', 'CompanyController@regCert'); //upload registration certificaate +Route::get('/delete/{id}', 'CompanyController@deletePost'); diff --git a/tests/Feature/CompanyTest.php b/tests/Feature/CompanyTest.php index 1a4a7fc..38038db 100644 --- a/tests/Feature/CompanyTest.php +++ b/tests/Feature/CompanyTest.php @@ -35,6 +35,7 @@ class CompanyTest extends TestCase 'company_name'=>'changed testing', 'registration_no'=>'testing', 'tax_no'=>'testing', + 'tax_no'=>'testing', 'tel_no'=>'12345', 'fax'=>'12345', 'address'=>'testing',