mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim-api.git
synced 2026-08-19 04:24:01 +00:00
Merge branch 'master' of gitlab.com:CIEFWorldwideSdnBhd/izyim-api into companyFrontend
# Conflicts: # public/company-profile.html
This commit is contained in:
+2
-1
@@ -1,7 +1,8 @@
|
||||
FROM php:7
|
||||
RUN apt-get update -y && apt-get install -y openssl zip unzip git netcat
|
||||
RUN apt-get update -y && apt-get install -y openssl zip unzip git netcat libpng-dev
|
||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||
RUN docker-php-ext-install pdo pdo_mysql
|
||||
RUN docker-php-ext-install gd
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
RUN composer update
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\PasswordResets;
|
||||
use JWTAuth;
|
||||
use Auth;
|
||||
use App\Role;
|
||||
use App\Company;
|
||||
|
||||
use Aloha\Twilio\Twilio;
|
||||
use Tymon\JWTAuth\Exceptions\JWTException;
|
||||
@@ -41,20 +42,20 @@ class AuthController extends Controller
|
||||
$user->save();
|
||||
|
||||
// create token if not exist, update if exist
|
||||
$token = mt_rand(0000,9999);
|
||||
$token = mt_rand(0000,9999);
|
||||
|
||||
// for testing
|
||||
// for testing
|
||||
if($request->phone == '0123456789'){
|
||||
$token = "1234";
|
||||
}
|
||||
|
||||
|
||||
$user_verification = $user->phoneVerification()->firstOrNew([
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
$user_verification->token = $token;
|
||||
$user_verification->save();
|
||||
|
||||
// TODO: send token to phone
|
||||
// TODO: send token to phone
|
||||
//$message = "RM0.00 IZYIM: Verification code : ". $token;
|
||||
//$twilio = new Twilio(env('TWILIO_ACC'), env('TWILIO_TOKEN'), env('TWILIO_NUMBER'));
|
||||
//$twilio->message($request->phone, $message);
|
||||
@@ -99,7 +100,10 @@ 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
|
||||
return response()->json(['success' => true, 'token' => $userToken,
|
||||
@@ -129,7 +133,7 @@ class AuthController extends Controller
|
||||
if($validator->fails()) {
|
||||
return response()->json(['success'=> false, 'error'=> $validator->messages()]);
|
||||
}
|
||||
|
||||
|
||||
$name = $request->name;
|
||||
$password = $request->password;
|
||||
$role = $request->role;
|
||||
@@ -142,6 +146,12 @@ class AuthController extends Controller
|
||||
// attach role to user
|
||||
$user->attachRole($role);
|
||||
$user->update(['name' => $name, 'password' => Hash::make($password)]);
|
||||
|
||||
// TODO : create company for user
|
||||
$company = new Company;
|
||||
$company->user = $user;
|
||||
$company->save();
|
||||
|
||||
return response()->json(['success'=> true, 'message'=> 'Profile updated.']);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,23 +6,16 @@ use Illuminate\Http\Request;
|
||||
use App\Company;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Validator;
|
||||
use Auth;
|
||||
|
||||
class CompanyController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
public function update(Request $request)
|
||||
{
|
||||
$input = $request->all();
|
||||
Company::create($input);
|
||||
return response()->json(['input'=>$input],201);
|
||||
//return redirect('/');
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$company = Company::find($id);
|
||||
$company = Company::where("user_id", Auth::user()->id)->first();
|
||||
if (!$company)
|
||||
{
|
||||
return response()->json(['message'=>'company not found'],200);
|
||||
return response()->json(['message'=>'company not found'], 404);
|
||||
}
|
||||
|
||||
$company->company_name=$request->input('company_name');
|
||||
@@ -41,9 +34,9 @@ class CompanyController extends Controller
|
||||
return response()->json(['company'=>$company],200);
|
||||
}
|
||||
|
||||
public function companyProfile(Request $request, $id)
|
||||
public function companyProfile(Request $request)
|
||||
{
|
||||
$company = Company::find($id);//find the company first
|
||||
$company = Company::where("user_id", Auth::user()->id)->first();
|
||||
if (!$company)
|
||||
{
|
||||
return response()->json(['message'=>'company for company_prof not found'],200);
|
||||
@@ -75,12 +68,12 @@ class CompanyController extends Controller
|
||||
return response()->json(['company'=>$company],200);
|
||||
}//end of companyProfile()
|
||||
|
||||
public function regCert(Request $request, $id)
|
||||
public function regCert(Request $request)
|
||||
{
|
||||
$company = Company::find($id); //find the company first
|
||||
$company = Company::where("user_id", Auth::user()->id)->first();
|
||||
if (!$company)
|
||||
{
|
||||
return response()->json(['message'=>'company for reg_cert not found'],200);
|
||||
return response()->json(['message'=>'Company not found'], 404);
|
||||
}
|
||||
|
||||
//validating file types
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Model Factories
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This directory should contain each of the model factory definitions for
|
||||
| your application. Factories provide a convenient way to generate new
|
||||
| model instances for testing / seeding your application's database.
|
||||
|
|
||||
*/
|
||||
// Manually creating the relationship tree.
|
||||
$factory->define(App\Company::class, function (Faker $faker) {
|
||||
return [
|
||||
'company_name'=>'testing',
|
||||
'registration_no'=>'testing',
|
||||
'tax_no'=>'testing',
|
||||
'tel_no'=>'12345',
|
||||
'fax'=>'12345',
|
||||
'address'=>'testing',
|
||||
'city'=>'testing',
|
||||
'postcode'=>'testing',
|
||||
'state'=>'testing',
|
||||
'country'=>'testing',
|
||||
'contact_person'=>'testing'
|
||||
];
|
||||
});
|
||||
@@ -25,6 +25,6 @@ class ChangeEmailToMobileFromUser extends Migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$table->renameColumn('phone', 'email');
|
||||
//$table->renameColumn('phone', 'email');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddUserToCompanyTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('companies', function (Blueprint $table) {
|
||||
$table->unsignedInteger('user_id');
|
||||
$table->foreign('user_id')->references('id')->on('users');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,6 @@
|
||||
|
||||
<div class="form-row">
|
||||
<a href="#" id="login" class="button block green" type="submit">Sign In</a>
|
||||
<a href="home.html" class="button block green" id="signin">Sign In</a>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
@@ -47,48 +47,38 @@
|
||||
<div class="form-element-title">
|
||||
<label style="color: #000">Role</label>
|
||||
</div>
|
||||
<select class="form-element">
|
||||
<select id="role" class="form-element">
|
||||
<option value="">Please select your role</option>
|
||||
<option value="1">Freight Forwarder</option>
|
||||
<option value="2">Importer</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-row no-padding">
|
||||
<div class="form-element-title">
|
||||
<label style="color: #000">First Name</label>
|
||||
<label style="color: #000">Full Name</label>
|
||||
</div>
|
||||
<input type="text" class="form-element" placeholder="Fedrick Darel" required />
|
||||
<input id="name"type="text" class="form-element" placeholder="Enter your full name" required />
|
||||
</div>
|
||||
|
||||
<div class="form-row no-padding">
|
||||
<div class="form-element-title">
|
||||
<label style="color: #000">Last Name</label>
|
||||
<label style="color: #000">Password</label>
|
||||
</div>
|
||||
<input type="text" class="form-element" placeholder="Auditore" required />
|
||||
<input id="password" type="password" class="form-element" placeholder="Enter your Password" required />
|
||||
</div>
|
||||
|
||||
<div class="form-row no-padding">
|
||||
<div class="form-element-title">
|
||||
<label style="color: #000">E-Mail</label>
|
||||
<label style="color: #000">Confirm Password</label>
|
||||
</div>
|
||||
<input type="text" class="form-element" placeholder="fedrickdarel@gmail.com" required />
|
||||
<input id="password_confirmation" type="password" class="form-element" placeholder="Enter the password again" required />
|
||||
</div>
|
||||
<div class="form-row no-padding">
|
||||
<div class="form-element-title">
|
||||
<label style="color: #000">Website</label>
|
||||
</div>
|
||||
<input type="text" class="form-element" placeholder="http://www.Azure.com" required />
|
||||
</div>
|
||||
<div class="form-row no-padding">
|
||||
<div class="form-element-title">
|
||||
<label style="color: #000">Position</label>
|
||||
</div>
|
||||
<input type="text" class="form-element" placeholder="CEO" required />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-divider"></div>
|
||||
|
||||
<div class="form-row txt-center">
|
||||
<a href="index.html" class="button block green">FINISH</a>
|
||||
<a href="#" id="pers-info" class="button block green">FINISH</a>
|
||||
</div>
|
||||
|
||||
<div class="form-divider"></div>
|
||||
@@ -104,6 +94,28 @@
|
||||
<script src="js/jquery-3.2.1.min.js"></script>
|
||||
<script src="js/global.script.js"></script>
|
||||
<!-- Require For All Pages -->
|
||||
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#pers-info').click(function() {
|
||||
$.ajax({
|
||||
type: "PATCH",
|
||||
url: "api/user",
|
||||
headers: {"Authorization": 'Bearer' + localStorage.getItem('token')},
|
||||
data: {
|
||||
role:$('#role').val(),
|
||||
name: $('#name').val(),
|
||||
password: $('#password').val(),
|
||||
password_confirmation:$('#password_confirmation').val()
|
||||
},
|
||||
success: function(data) {
|
||||
document.location.href="index.html";
|
||||
},
|
||||
error: function() {
|
||||
alert("Failed");}
|
||||
})
|
||||
})
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,100 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>AzureUI - SIGNUP</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>AzureUI - SIGN-IN</title>
|
||||
<link href="https://fonts.googleapis.com/css?family=Nunito:300,400,600,700,900" rel="stylesheet">
|
||||
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/global.style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="wrapper">
|
||||
<div class="wrapper-inline">
|
||||
|
||||
<!-- Header area start -->
|
||||
<header style="background-color: #FFF">
|
||||
<a class="go-back-link-index" href="javascript:history.back();"><i class="fa fa-arrow-left"></i></a>
|
||||
<h1 id="HT" class="page-title" style="color: #000">Sign-up</h1>
|
||||
</header>
|
||||
<!-- Header area end -->
|
||||
|
||||
<div class="form-divider"></div>
|
||||
<div class="form-row txt-center">
|
||||
<img src="images/CIEF.png" style="width:200px; height:100px">
|
||||
</div>
|
||||
|
||||
<!-- Page content start -->
|
||||
<main>
|
||||
<section class="container">
|
||||
<form>
|
||||
<div class="form-row-group with-icons">
|
||||
<div class="form-row no-padding">
|
||||
<div style="position:absolute; top: 10px;">
|
||||
<i class="fa fa-user" style="color: #667F97"></i>
|
||||
</div>
|
||||
<select class="form-element">
|
||||
<option value="">Role</option>
|
||||
<option value="1" selected>Importer</option>
|
||||
<option value="2">Forwarder</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-row no-padding">
|
||||
<div style="position:absolute; top: 10px;">
|
||||
<i class="fa fa-lock" style="color: #667F97"></i>
|
||||
</div>
|
||||
<input type="password" name="aaa" class="form-element" placeholder="Password" required>
|
||||
</div>
|
||||
<div class="form-row no-padding">
|
||||
<div style="position:absolute; top: 10px;">
|
||||
<i class="fa fa-lock" style="color: #667F97"></i>
|
||||
</div>
|
||||
<input type="password" name="aaa" class="form-element" placeholder="Confirm Password" required>
|
||||
</div>
|
||||
<div class="form-row no-padding">
|
||||
<div style="position:absolute; top: 10px;">
|
||||
<i class="fa fa-check" style="color: #667F97"></i>
|
||||
</div>
|
||||
<input type="text" name="aaa" class="form-element" placeholder="Verification No" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-divider"></div>
|
||||
<div class="form-row txt-center" style="color:white">
|
||||
Request verification number
|
||||
</div>
|
||||
|
||||
<div class="form-row-group with-icons">
|
||||
<div class="form-row no-padding">
|
||||
<div style="position:absolute; top: 10px;">
|
||||
<i class="fa fa-phone" style="color: #667F97"></i>
|
||||
</div>
|
||||
<input type="text" name="aaa" class="form-element" placeholder="Mobile No">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-divider"></div>
|
||||
<a href="#" class="button blue" style="right: 50px">Send</a>
|
||||
<div class="form-divider"></div>
|
||||
<div class="form-label-divider"></div>
|
||||
<div class="form-divider"></div>
|
||||
|
||||
<div >
|
||||
<a href="verify-terms-conditions.html" class="button block green">Sign Up</a>
|
||||
</div>
|
||||
|
||||
<div class="form-row txt-center">
|
||||
Already have an account? <a href="index.html" data-loader="show">Sign-in</a>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</section>
|
||||
</main>
|
||||
<!-- Page content end -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -15,11 +15,11 @@
|
||||
<div class="form-divider"></div>
|
||||
|
||||
<div class="form-row txt-center aztitle">
|
||||
Verify +60 19-795-1905
|
||||
Verify Phone
|
||||
</div>
|
||||
|
||||
<div class="form-row txt-center">
|
||||
Waiting to automatically detect an SMS sent to <b>+60 19-795 1905</b>.<a> Wrong number?</a>
|
||||
A verification code has been send to <b><span id="phone"></span></b>.<a><br> Wrong number?</a>
|
||||
</div>
|
||||
|
||||
<div class="form-divider"></div>
|
||||
@@ -32,15 +32,15 @@
|
||||
<div class="form-element-code">
|
||||
<label style="color: #000">Enter Verification Code</label>
|
||||
</div>
|
||||
<input type="text" class="form-element-code-input" placeholder="" required />
|
||||
<input type="text" id="verify-code" class="form-element-code-input" placeholder="" required />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- AzFooter Start Here-->
|
||||
<div class="azfooter-code">
|
||||
<div class="azfmain-button">
|
||||
<div class="azfooter-code" id="btn-verify" style="margin-top:50px">
|
||||
<div class="azfmain-button" >
|
||||
<div class="form-row txt-center">
|
||||
<a href="profile-first-setup.html" class="button block green">NEXT</a>
|
||||
<a href="#" class="button block green">NEXT</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -51,6 +51,47 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
function readCookie(name) {
|
||||
var nameEQ = encodeURIComponent(name) + "=";
|
||||
var ca = document.cookie.split(';');
|
||||
for (var i = 0; i < ca.length; i++) {
|
||||
var c = ca[i];
|
||||
while (c.charAt(0) === ' ')
|
||||
c = c.substring(1, c.length);
|
||||
if (c.indexOf(nameEQ) === 0)
|
||||
return decodeURIComponent(c.substring(nameEQ.length, c.length));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
var phone = readCookie('phone');
|
||||
document.getElementById("phone").innerHTML = phone;
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#btn-verify').click(function() {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "api/verify-phone",
|
||||
data: {
|
||||
phone: phone,
|
||||
token: $('#verify-code').val()},
|
||||
success: function(data) {
|
||||
if( data.success){
|
||||
document.location.href="profile-first-setup.html";
|
||||
localStorage.token = data.data.token;
|
||||
}
|
||||
else{
|
||||
console.log('wrong code');
|
||||
}
|
||||
//
|
||||
},
|
||||
error: function() {
|
||||
alert("Failed");}
|
||||
});
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -8,8 +8,8 @@
|
||||
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/global.style.css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<div class="wrapper-inline">
|
||||
<div class="form-divider"></div>
|
||||
@@ -19,15 +19,16 @@
|
||||
</div>
|
||||
|
||||
<div class="form-row txt-center">
|
||||
IZYIM will send an SMS message to verify your phone number. Enter your country code and phone number:
|
||||
IZYIM will send an SMS message to verify your phone number. Enter your country code and phone number:
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-divider"></div>
|
||||
|
||||
<!-- Here Lies Main Start Here -->
|
||||
<main>
|
||||
<section class="container">
|
||||
<form></form>
|
||||
<form>
|
||||
@csrf
|
||||
<div class="form-row-group with-icons">
|
||||
|
||||
<div class="form-row no-padding">
|
||||
@@ -45,7 +46,7 @@
|
||||
<div style="position:absolute; top:10px">
|
||||
<a class="fa fa-phone"></a>
|
||||
</div>
|
||||
<input id="mobile" type="text" class="form-element" placeholder="Enter your phone number" />
|
||||
<input id="mobile" type="text" class="form-element" placeholder="Enter your phone number" required />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -53,7 +54,7 @@
|
||||
<div class="azfooter">
|
||||
<div class="azfmain-button">
|
||||
<div class="form-row txt-center">
|
||||
<a href="verify-code-number.html" class="button block green">NEXT</a>
|
||||
<a href="#" id="send-verification" class="button block green">NEXT</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="azfmain-txt">
|
||||
@@ -61,14 +62,47 @@
|
||||
Carrier SMS charges may apply
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- AzFooter Ended Here -->
|
||||
|
||||
</div> <!-- AzFooter Ended Here -->
|
||||
</form>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
function createCookie(name, value, days) {
|
||||
var expires;
|
||||
|
||||
if (days) {
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
||||
expires = "; expires=" + date.toGMTString();
|
||||
} else {
|
||||
expires = "";
|
||||
}
|
||||
document.cookie = encodeURIComponent(name) + "=" + encodeURIComponent(value) + expires + "; path=/";
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#send-verification').click(function() {
|
||||
var mobile = $('#mobile').val();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "api/send-verification",
|
||||
data: {
|
||||
phone: $('#mobile').val()},
|
||||
success: function(data) {
|
||||
document.location.href="verify-code-number.html";
|
||||
},
|
||||
Cookies:createCookie('phone', mobile, 60),
|
||||
error: function() {
|
||||
alert("Failed");}
|
||||
});
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+5
-5
@@ -26,10 +26,10 @@ Route::group(['middleware' => ['jwt.auth']], function() {
|
||||
Route::get('test', function(Request $request){
|
||||
return response()->json(['user'=> $request->user()]);
|
||||
});
|
||||
|
||||
/* 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
|
||||
});
|
||||
|
||||
/* Company */
|
||||
Route::post('/company', 'CompanyController@store'); //store company information
|
||||
Route::put('/company/{company}', 'CompanyController@update'); //update company information
|
||||
Route::post('/company/company_profile/{companyID}', 'CompanyController@companyProfile');//upload company profile picture
|
||||
Route::post('/company/reg_cert/{companyID}', 'CompanyController@regCert'); //upload registration certificaate
|
||||
@@ -7,40 +7,31 @@ use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Artisan;
|
||||
use App\User;
|
||||
use App\Company;
|
||||
|
||||
class CompanyTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testExample()
|
||||
protected $company;
|
||||
protected $user;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
parent::setUp();
|
||||
Artisan::call('db:seed');
|
||||
$this->user = factory(User::class)->create();
|
||||
$this->company = $this->user->each(function ($u) {
|
||||
factory(Company::class)->create([
|
||||
'user_id' => $u->id,
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
public function testPOST()
|
||||
public function testUpdateCompany()
|
||||
{
|
||||
$response = $this->json('POST', '/api/company', [
|
||||
'company_name'=>'testing',
|
||||
'registration_no'=>'testing',
|
||||
'tax_no'=>'testing',
|
||||
'tel_no'=>'12345',
|
||||
'fax'=>'12345',
|
||||
'address'=>'testing',
|
||||
'city'=>'testing',
|
||||
'postcode'=>'testing',
|
||||
'state'=>'testing',
|
||||
'country'=>'testing',
|
||||
'contact_person'=>'testing',
|
||||
]);
|
||||
$response->assertStatus(201);
|
||||
}
|
||||
|
||||
public function testPUT()
|
||||
{
|
||||
$response = $this->json('PUT', '/api/company/2', [
|
||||
$response = $this->actingAs($this->user)
|
||||
->patchJson('/api/company', [
|
||||
'company_name'=>'changed testing',
|
||||
'registration_no'=>'testing',
|
||||
'tax_no'=>'testing',
|
||||
@@ -52,29 +43,32 @@ class CompanyTest extends TestCase
|
||||
'state'=>'testing',
|
||||
'country'=>'testing',
|
||||
'contact_person'=>'testing',
|
||||
|
||||
]);
|
||||
$response->assertStatus(200);
|
||||
|
||||
}
|
||||
|
||||
public function testcompanyProfile()
|
||||
{
|
||||
public function testUploadCompanyProfile()
|
||||
{
|
||||
Storage::fake('company_profile');
|
||||
|
||||
$response = $this->json('POST', '/api/company/company_profile/2', [
|
||||
|
||||
$response = $this->actingAs($this->user)
|
||||
->json('POST', '/api/company/company_profile/', [
|
||||
'company_profile' => UploadedFile::fake()->image('comp.jpg')
|
||||
]);
|
||||
dd($response->getContent());
|
||||
// dd($response->getContent());
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
public function testregCert()
|
||||
public function testUploadRegCert()
|
||||
{
|
||||
Storage::fake('reg_cert');
|
||||
|
||||
$response = $this->json('POST', '/api/company/reg_cert/2', [
|
||||
$response = $this->actingAs($this->user)
|
||||
->json('POST', '/api/company/reg_cert/', [
|
||||
'reg_cert' => UploadedFile::fake()->create('document.pdf')//, $sizeInKilobytes)
|
||||
]);
|
||||
dd($response->getContent());
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ class LoginTest extends TestCase
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testExample()
|
||||
public function testLogin()
|
||||
{
|
||||
$response = $this->json('POST', '/api/login', ['phone' => '0123456789','password' => 'secret']);
|
||||
$response
|
||||
|
||||
@@ -26,7 +26,7 @@ class RegisterTest extends TestCase
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$response = $this->json('POST', '/api/verify', ['phone' => '0123456789', 'token' => '1234']);
|
||||
$response = $this->json('POST', '/api/verify-phone', ['phone' => '0123456789', 'token' => '1234']);
|
||||
$response
|
||||
->assertStatus(200)
|
||||
->assertJson([
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBasicTest()
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user