mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim-api.git
synced 2026-08-19 04:24:01 +00:00
Merge branch 'asif/contact' of gitlab.com:CIEFWorldwideSdnBhd/izyim-api into asif/warehouses
# Conflicts: # app/Http/Controllers/CompanyController.php # package-lock.json # routes/api.php
This commit is contained in:
@@ -12,3 +12,4 @@ Homestead.yaml
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
.env
|
||||
.lock
|
||||
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
FROM php:7
|
||||
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
|
||||
ADD start.sh /start.sh
|
||||
CMD ["/start.sh"]
|
||||
@@ -10,6 +10,12 @@ class Company extends Model
|
||||
protected $fillable = ['user_id', 'company_profile', 'reg_cert', 'company_name', 'registration_no', 'tax_no', 'tel_no', 'fax', 'address', 'city', 'postcode', 'state', 'country', 'contact_person'];
|
||||
//protected $guarded = [];
|
||||
|
||||
|
||||
public function Contact()
|
||||
|
||||
{
|
||||
return $this->hasMany(Contact::class);
|
||||
}
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\User');
|
||||
|
||||
+21
-1
@@ -6,5 +6,25 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Contact extends Model
|
||||
{
|
||||
protected $fillable = ['user_id','company_id'];
|
||||
protected $fillable = ['company_id'];
|
||||
|
||||
|
||||
|
||||
public function User()
|
||||
|
||||
{
|
||||
|
||||
return $this->belongsTo(User::class);
|
||||
|
||||
}
|
||||
public function Company()
|
||||
|
||||
{
|
||||
|
||||
return $this->belongsTo(Company::class);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,28 @@ use Auth;
|
||||
|
||||
class CompanyController extends Controller
|
||||
{
|
||||
public function search(Request $request)
|
||||
{
|
||||
if($request->search == ''){
|
||||
return '';
|
||||
}
|
||||
$output= array();
|
||||
$matchedTerms = Company::where('company_name', 'LIKE','%'. $request->search . '%')->get();
|
||||
//return response()->json($matchedTerm);
|
||||
|
||||
if($matchedTerms)
|
||||
{
|
||||
foreach ($matchedTerms as $key => $matchedTerm)
|
||||
{
|
||||
array_push($output, ['company_name' => $matchedTerm->company_name, 'tel_no' => $matchedTerm->tel_no,
|
||||
'contact_person'=>$matchedTerm->contact_person ]);
|
||||
}
|
||||
|
||||
return response($output);
|
||||
}
|
||||
else{return "error";}
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
$company = Company::where("user_id", Auth::user()->id)->first();
|
||||
|
||||
@@ -3,120 +3,79 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Contact;
|
||||
use App\Company;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ContactController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$contact=Contact::all();
|
||||
$response=[
|
||||
|
||||
'contact'=>$contact
|
||||
|
||||
];
|
||||
return response()->json($contact, 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
// get company id from request ex: $request->input('company_id')
|
||||
// $company_id = $request->input('company_id'))
|
||||
// get company id from request ex:
|
||||
//$request->input('company_id');
|
||||
$company_id = $request->input('company_id');
|
||||
// query to find company asisng to $company
|
||||
$company = Company::find($company_id);
|
||||
|
||||
// query to find company asisng to $company
|
||||
// $company = Comapny::find($company_id)
|
||||
|
||||
// get user from session $request->user();
|
||||
// $user = $request->user();
|
||||
// get user from session
|
||||
//$request->user();
|
||||
$user = $request->user();
|
||||
|
||||
// prepare query
|
||||
|
||||
|
||||
$contact = new Contact();
|
||||
$contact->company_id = $company->id;
|
||||
$contact->user_id = $user->id;
|
||||
$contact->save();
|
||||
// insert into database
|
||||
|
||||
|
||||
return response()->json($contact, 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
// $contact = Contact::find($id);
|
||||
// if (!$contact)
|
||||
// {
|
||||
// return response()->json(['message'=>'ID not found'],200);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// $contact->ff_id=$request->input('ff_id');
|
||||
//
|
||||
//
|
||||
// $contact->save();
|
||||
// return response()->json(['contact'=>$contact],200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$contact=Contact::find($id);
|
||||
$contact = Contact::where("user_id", Auth::user()->id)->where('id', $id)->first();
|
||||
//$contact=Contact::find($id);
|
||||
$contact->delete();
|
||||
|
||||
return response()->json($contact, 204);
|
||||
}
|
||||
|
||||
public function postApprove(Request $request, $id)
|
||||
{
|
||||
$contact = Contact::where("user_id", Auth::user()->id)->where('id', $id)->first();
|
||||
//$contact = Contact::where('id', '=', e($id))->first();
|
||||
if($contact)
|
||||
{
|
||||
$action=$request->input('action');
|
||||
if ($action==1)
|
||||
{
|
||||
$contact->status=1;
|
||||
}
|
||||
if ($action==0)
|
||||
{
|
||||
$contact->status=0;
|
||||
}
|
||||
else{
|
||||
return response()->json(["message" => "not allowed"], 400);
|
||||
}
|
||||
|
||||
$saved = $contact->save();
|
||||
if ($saved){
|
||||
return response()->json($contact, 201);
|
||||
}
|
||||
return response()->json($contact, 400);
|
||||
|
||||
// $contact = $request->input('id');
|
||||
// $contact->status = 1;
|
||||
// $contact->save();
|
||||
//return redirect()->back()->with('info','Request has been approved ');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Contact;
|
||||
use App\Warehouse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -111,5 +112,6 @@ class WarehouseController extends Controller
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
|
||||
}
|
||||
}
|
||||
Generated
-5118
File diff suppressed because it is too large
Load Diff
+3
-3
@@ -43,9 +43,9 @@ return [
|
||||
'driver' => 'mysql',
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => env('DB_DATABASE', 'forgzze'),
|
||||
'username' => env('DB_USERNAME', 'forge'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'database' => env('DB_DATABASE', 'izyim1'),
|
||||
'username' => env('DB_USERNAME', 'izyim1'),
|
||||
'password' => env('DB_PASSWORD', 'izyim1'),
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
'charset' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
|
||||
@@ -15,7 +15,7 @@ class CreateContactsTable extends Migration
|
||||
{
|
||||
Schema::create('contacts', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->foreign('user_id')
|
||||
|
||||
->references('id')->on('users')
|
||||
|
||||
Generated
-17780
File diff suppressed because it is too large
Load Diff
+94
-142
@@ -22,7 +22,9 @@
|
||||
<div class="search-result-header fix-searchbar">
|
||||
<!-- or without .fix-searchbar -->
|
||||
<form class="fix-searchbar">
|
||||
<input type="text" id="searchInput" class="form-element" placeholder="search by company/phone no/name" onkeyup="CSearch()">
|
||||
<input type="text" id="search" name="search" class="form-element" placeholder="search by company/phone no/name">
|
||||
<!--
|
||||
<input type="text" id="searchInput" class="form-element" placeholder="search by company/phone no/name" onkeyup="CSearch()">-->
|
||||
<button id="btnback" type="button" class="search-result-btn"><i class="fa fa-arrow-left"></i></button>
|
||||
</form>
|
||||
</div>
|
||||
@@ -60,124 +62,8 @@
|
||||
</div>
|
||||
<!-- Menu navigation start -->
|
||||
<div class="cont-container">
|
||||
<ul id="AddCompany" class="main-menu" style="display: none; background-color: #FFF">
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fa fa-user"></i>
|
||||
Fedrick Darel Auditore
|
||||
<span class="list-item-title-role" style="margin-top:-10px">0197951905</span>
|
||||
<br />
|
||||
<span class="list-item-title-role" style="margin-top:-10px">Azure Corp</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fa fa-user"></i>
|
||||
Alexander
|
||||
<span class="list-item-title-role" style="margin-top:-10px">0197518811</span>
|
||||
<br />
|
||||
<span class="list-item-title-role" style="margin-top:-10px">Roma Inc</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fa fa-user"></i>
|
||||
Rovio Dough
|
||||
<span class="list-item-title-role" style="margin-top:-10px">0193319013</span>
|
||||
<br />
|
||||
<span class="list-item-title-role" style="margin-top:-10px">Rovio Games</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fa fa-user"></i>
|
||||
Mark
|
||||
<span class="list-item-title-role" style="margin-top:-10px">0127953102</span>
|
||||
<br />
|
||||
<span class="list-item-title-role" style="margin-top:-10px">Facebook</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fa fa-user"></i>
|
||||
Bruce Wayne
|
||||
<span class="list-item-title-role" style="margin-top:-10px">0131131521</span>
|
||||
<br />
|
||||
<span class="list-item-title-role" style="margin-top:-10px">Wayne Enterprise</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fa fa-user"></i>
|
||||
Daniel Jake
|
||||
<span class="list-item-title-role" style="margin-top:-10px">0127224135</span>
|
||||
<br />
|
||||
<span class="list-item-title-role" style="margin-top:-10px">Daniel Inc</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fa fa-user"></i>
|
||||
Harry
|
||||
<span class="list-item-title-role" style="margin-top:-10px">0163124451</span>
|
||||
<br />
|
||||
<span class="list-item-title-role" style="margin-top:-10px">CIEF</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fa fa-user"></i>
|
||||
Kiah Wang Auditore
|
||||
<span class="list-item-title-role" style="margin-top:-10px">0117951905</span>
|
||||
<br />
|
||||
<span class="list-item-title-role" style="margin-top:-10px">Land Estate Inc</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fa fa-user"></i>
|
||||
Spongebob
|
||||
<span class="list-item-title-role" style="margin-top:-10px">0161233255</span>
|
||||
<br />
|
||||
<span class="list-item-title-role" style="margin-top:-10px">Karate Corp</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fa fa-user"></i>
|
||||
Zack Synder
|
||||
<span class="list-item-title-role" style="margin-top:-10px">0122451105</span>
|
||||
<br />
|
||||
<span class="list-item-title-role" style="margin-top:-10px">DC Entertainment</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fa fa-user"></i>
|
||||
Alice Wong Auditore
|
||||
<span class="list-item-title-role" style="margin-top:-10px">0167951155</span>
|
||||
<br />
|
||||
<span class="list-item-title-role" style="margin-top:-10px">Alliance Estate</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fa fa-user"></i>
|
||||
Violet Auditore Firenze
|
||||
<span class="list-item-title-role" style="margin-top:-10px">0122311975</span>
|
||||
<br />
|
||||
<span class="list-item-title-role" style="margin-top:-10px">MC Muzic Inc</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fa fa-user"></i>
|
||||
Jack Ma
|
||||
<span class="list-item-title-role" style="margin-top:-10px">0127611005</span>
|
||||
<br />
|
||||
<span class="list-item-title-role" style="margin-top:-10px">Alibaba Express</span>
|
||||
</a>
|
||||
</li>
|
||||
<ul id="AddCompany" class="main-menu" style="background-color: #FFF">
|
||||
|
||||
</ul>
|
||||
<div class="form-divider"></div>
|
||||
</div>
|
||||
@@ -198,37 +84,103 @@
|
||||
|
||||
</div>
|
||||
<!-- Wrapper Content End Here -->
|
||||
|
||||
<div class="popup-overlay" id="formPopup5" style="display: none">
|
||||
<!-- if you dont want overlay add class .no-overlay -->
|
||||
<div class="popup-container">
|
||||
<div class="popup-header">
|
||||
<h3 class="popup-title" >Add a Contact</h3>
|
||||
<span class="popup-close" data-dismiss="true"><i class="fa fa-times"></i></span>
|
||||
</div>
|
||||
<div class="popup-content">
|
||||
|
||||
<div class="form-row-group with-icons-no-padding">
|
||||
<div class="form-row no-padding">
|
||||
<div class="form-element-title">
|
||||
<label style="color: #000">Company Name</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-divider"></div>
|
||||
|
||||
<div class="form-row no-padding">
|
||||
<div class="form-element-title">
|
||||
<label style="color: #000">Telephone number</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-divider"></div>
|
||||
|
||||
<div class="form-row no-padding">
|
||||
<div class="form-element-title">
|
||||
<label style="color: #000">Contact Person</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-divider"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="popup-footer">
|
||||
<button class="button blue" id="addContact" data-dismiss="true">Add Contact</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Required For All Pages, Otherwise Ugly Others Function Won't Work -->
|
||||
<script src="js/jquery-3.2.1.min.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script src="js/global.script.js"></script>
|
||||
<!-- Required For All Pages, Otherwise Ugly Others Function Won't Work -->
|
||||
|
||||
<script type="text/javascript">
|
||||
function CSearch() {
|
||||
// Declare variables
|
||||
var input, filter, ul, li, a, i;
|
||||
input = document.getElementById('searchInput');
|
||||
filter = input.value.toUpperCase();
|
||||
ul = document.getElementById("AddCompany");
|
||||
li = ul.getElementsByTagName('li');
|
||||
if (input.value.length == 0) {
|
||||
ul.style.display = "none";
|
||||
} else {
|
||||
ul.style.display = "block";
|
||||
}
|
||||
// Loop through all list items, and hide those who don't match the search query
|
||||
for (i = 0; i < li.length; i++) {
|
||||
a = li[i].getElementsByTagName("a")[0];
|
||||
if (a.innerHTML.toUpperCase().indexOf(filter) > -1) {
|
||||
li[i].style.display = "block";
|
||||
} else {
|
||||
li[i].style.display = "none";
|
||||
$('#search').on('keyup', function(){
|
||||
$('#AddCompany').empty();
|
||||
var ul, li;
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "api/company/search",
|
||||
headers: {"Authorization": 'Bearer' + localStorage.getItem('token')},
|
||||
data: {search: $('#search').val()},
|
||||
|
||||
success:function(data){
|
||||
console.log(data);
|
||||
for(i=0; i<data.length; i++){
|
||||
$('#AddCompany').append('<li style="display: show;"> <a href="#" onclick="displayCompany()"> <i class="fa fa-user"></i>' + data[i].company_name + '<span class="list-item-title-role" style="margin-top:-10px">' + data[i].tel_no + '</span> <br> <span class="list-item-title-role" style="margin-top:-10px">'+ data[i].contact_person);
|
||||
}
|
||||
//$('#AddCompany').show();
|
||||
},
|
||||
error:function(data){
|
||||
console.log(data);
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
function displayCompany(){
|
||||
$('#formPopup5').show();
|
||||
|
||||
}
|
||||
document.getElementById("btnback").onclick = function () {
|
||||
javascript: history.back();
|
||||
};
|
||||
// function CSearch() {
|
||||
// // Declare variables
|
||||
// var input, filter, ul, li, a, i;
|
||||
// input = document.getElementById('searchInput');
|
||||
// filter = input.value.toUpperCase();
|
||||
// ul = document.getElementById("AddCompany");
|
||||
// li = ul.getElementsByTagName('li');
|
||||
// if (input.value.length == 0) {
|
||||
// ul.style.display = "none";
|
||||
// } else {
|
||||
// ul.style.display = "block";
|
||||
// }
|
||||
// // Loop through all list items, and hide those who don't match the search query
|
||||
// for (i = 0; i < li.length; i++) {
|
||||
// a = li[i].getElementsByTagName("a")[0];
|
||||
// if (a.innerHTML.toUpperCase().indexOf(filter) > -1) {
|
||||
// li[i].style.display = "block";
|
||||
// } else {
|
||||
// li[i].style.display = "none";
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// document.getElementById("btnback").onclick = function () {
|
||||
// javascript: history.back();
|
||||
// };
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
+12
-9
@@ -12,12 +12,6 @@ use App\Company;
|
||||
| is assigned the "api" middleware group. Enjoy building your API!
|
||||
|
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Route::middleware('auth:api')->get('/user', function (Request $request) {
|
||||
// return $request->user();
|
||||
//});
|
||||
@@ -25,6 +19,8 @@ use App\Company;
|
||||
Route::post('register', 'AuthController@register');
|
||||
/* Authentication */
|
||||
Route::post('login', 'AuthController@login');
|
||||
|
||||
//Route::post('recover', 'AuthController@recover');
|
||||
//
|
||||
//Route::group(['middleware' => ['jwt.auth']], function() {
|
||||
// Route::get('logout', 'AuthController@logout');
|
||||
@@ -40,14 +36,18 @@ Route :: get('/warehouse','WarehouseController@index');
|
||||
|
||||
|
||||
|
||||
Route :: delete('/contacts/{ff_id}','ContactController@destroy');
|
||||
Route :: delete('/contacts/{contacts_id}','ContactController@destroy');
|
||||
Route :: get('/contacts','ContactController@index');
|
||||
Route :: post('/contacts','ContactController@store');
|
||||
//Route :: post('/contacts','ContactController@store');
|
||||
|
||||
|
||||
Route::post('password/recover', 'AuthController@recover');
|
||||
Route::post('password/reset', 'AuthController@reset');
|
||||
Route::post('send-verification', 'AuthController@sendVerification');
|
||||
Route::post('verify-phone', 'AuthController@verifyPhone');
|
||||
|
||||
|
||||
Route::group(['middleware' => ['jwt.auth']], function() {
|
||||
Route::get('logout', 'AuthController@logout');
|
||||
Route::patch('user', 'AuthController@updateUser');
|
||||
@@ -72,6 +72,10 @@ Route::group(['middleware' => ['jwt.auth']], function() {
|
||||
Route::post('/company', 'CompanyController@store'); //store company information
|
||||
Route::put('/company/{company}', 'CompanyController@update'); //update company information
|
||||
Route::get('/company/search/{company_name}', 'CompanyController@search');
|
||||
/* Contacts */
|
||||
Route::get('/company/search', 'CompanyController@search');
|
||||
//Route::get('/company/search/{company_name}', 'CompanyController@search');//search company in contacts
|
||||
Route::post('/contacts/{company_id}/request', 'ContactController@postApprove');
|
||||
|
||||
//Route::post('/company', 'CompanyController@uploadImage');
|
||||
|
||||
@@ -85,5 +89,4 @@ Route::get('/company/search/{company_name}', 'CompanyController@search');
|
||||
// $company = Product::findOrFail($companyId);
|
||||
// $company->update($request->all());
|
||||
// return $company;
|
||||
// });
|
||||
|
||||
// });
|
||||
@@ -11,6 +11,14 @@ abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
use CreatesApplication;
|
||||
|
||||
protected function headers($user = null)
|
||||
{
|
||||
$token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC8xMjcuMC4wLjE6ODAwMFwvYXBpXC9sb2dpbiIsImlhdCI6MTUyNjQ1ODExMiwiZXhwIjoxNTI3NjY3NzEyLCJuYmYiOjE1MjY0NTgxMTIsImp0aSI6InVnOFJnellnbzlVNWxWQ1kiLCJzdWIiOjUsInBydiI6Ijg3ZTBhZjFlZjlmZDE1ODEyZmRlYzk3MTUzYTE0ZTBiMDQ3NTQ2YWEifQ.NosAWtXlIPzGVYYz46CoPhseo0WQPQZpuR1t9mCwvX0";
|
||||
$headers = ['HTTP_Authorization' => 'Bearer '.$token];
|
||||
|
||||
return $headers;
|
||||
}
|
||||
protected $user;
|
||||
|
||||
public function actingAs(UserContract $user, $driver = null)
|
||||
|
||||
+31
-99
@@ -10,111 +10,43 @@ use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
|
||||
class contactTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBasicExample()
|
||||
{
|
||||
$response = $this->json('POST', '/api/contacts', ['ff_id' => '14']);
|
||||
|
||||
$response
|
||||
->assertStatus(201);
|
||||
// ->assertJson(
|
||||
// [
|
||||
// 'success' => true,
|
||||
// 'message' => 'Success'
|
||||
// //'response' => [
|
||||
// // 'id' => $contacts->ff_id,
|
||||
// // ]
|
||||
// ]);
|
||||
}
|
||||
|
||||
|
||||
public function testGet()
|
||||
// {
|
||||
// $response = $this->json('GET', '/api/contacts');
|
||||
//
|
||||
// $response
|
||||
// ->assertStatus(200);
|
||||
//
|
||||
// }
|
||||
{
|
||||
$response = $this->json('GET', '/api/company/search/cief');
|
||||
|
||||
$response
|
||||
->assertStatus(200);
|
||||
|
||||
}
|
||||
|
||||
public function testStoreId()
|
||||
{
|
||||
$response = $this->get('/api/contacts');
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
// public function testUPdate()
|
||||
// {
|
||||
//
|
||||
// $response = $this->json('PUT', '/api/warehouse/{war_id}' . $article->id, $payload, $headers)
|
||||
// ->assertStatus(200)
|
||||
// ->assertJson([
|
||||
// 'id' => 1,
|
||||
// 'title' => 'Lorem',
|
||||
// 'body' => 'Ipsum'
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// public function testPostWarehouse()
|
||||
// {
|
||||
// $response = $this->json('POST', '/api/warehouse', [
|
||||
//
|
||||
// 'address'=> '2d',
|
||||
// 'city'=>'cj ',
|
||||
// 'zip'=>' 123',
|
||||
// 'state' =>' sl',
|
||||
// 'contact_person' =>'asif ',
|
||||
// 'contact_person_no' =>'1212122 ',
|
||||
// 'branch'=>'yap ',
|
||||
// 'country' =>' ba',
|
||||
// 'company_id' =>'1212 '
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// ]);
|
||||
//
|
||||
// $response
|
||||
// ->assertStatus(201);
|
||||
//// ->assertJson([
|
||||
//// 'created' => true,
|
||||
// // ]
|
||||
// //);
|
||||
// }
|
||||
|
||||
public function testPutWarehouse()
|
||||
{
|
||||
$response = $this->json('PUT', '/api/warehouse/6', [
|
||||
|
||||
'address'=> '2g',
|
||||
'city'=>'cj ',
|
||||
'zip'=>' 123',
|
||||
'state' =>' sl',
|
||||
'contact_person' =>'tuytguy',
|
||||
'contact_person_no' =>'1212122 ',
|
||||
'branch'=>'yap ',
|
||||
'country' =>' ba',
|
||||
'company_id' =>'1212 '
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
]);
|
||||
|
||||
$response = $this->json('POST', '/api/contacts', ['company_id' => '1'], $this->headers());
|
||||
$response
|
||||
->assertStatus(200);
|
||||
// ->assertJson([
|
||||
//
|
||||
// ]
|
||||
// );
|
||||
->assertStatus(201);
|
||||
|
||||
}
|
||||
|
||||
// public function testDeleteContacts()
|
||||
// {
|
||||
//
|
||||
// $response = $this->json('DELETE', '/api/contacts/1');
|
||||
//
|
||||
// $response
|
||||
// ->assertStatus(204);
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
|
||||
public function testApprove()
|
||||
{
|
||||
$response = $this->json('POST', '/api/contacts/1/request', ['action' => 1]);
|
||||
$response
|
||||
->assertStatus(200);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\warehouseTest;
|
||||
namespace Tests\API;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
|
||||
class warehouseTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBasicExample()
|
||||
{
|
||||
$response = $this->json('POST', '/api/contacts', ['ff_id' => '14']);
|
||||
|
||||
$response
|
||||
->assertStatus(201);
|
||||
// ->assertJson(
|
||||
// [
|
||||
// 'success' => true,
|
||||
// 'message' => 'Success'
|
||||
// //'response' => [
|
||||
// // 'id' => $contacts->ff_id,
|
||||
// // ]
|
||||
// ]);
|
||||
}
|
||||
|
||||
|
||||
public function testGet()
|
||||
// {
|
||||
// $response = $this->json('GET', '/api/contacts');
|
||||
//
|
||||
// $response
|
||||
// ->assertStatus(200);
|
||||
//
|
||||
// }
|
||||
{
|
||||
$response = $this->get('/api/contacts');
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
// public function testUPdate()
|
||||
// {
|
||||
//
|
||||
// $response = $this->json('PUT', '/api/warehouse/{war_id}' . $article->id, $payload, $headers)
|
||||
// ->assertStatus(200)
|
||||
// ->assertJson([
|
||||
// 'id' => 1,
|
||||
// 'title' => 'Lorem',
|
||||
// 'body' => 'Ipsum'
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// public function testPostWarehouse()
|
||||
// {
|
||||
// $response = $this->json('POST', '/api/warehouse', [
|
||||
//
|
||||
// 'address'=> '2d',
|
||||
// 'city'=>'cj ',
|
||||
// 'zip'=>' 123',
|
||||
// 'state' =>' sl',
|
||||
// 'contact_person' =>'asif ',
|
||||
// 'contact_person_no' =>'1212122 ',
|
||||
// 'branch'=>'yap ',
|
||||
// 'country' =>' ba',
|
||||
// 'company_id' =>'1212 '
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// ]);
|
||||
//
|
||||
// $response
|
||||
// ->assertStatus(201);
|
||||
//// ->assertJson([
|
||||
//// 'created' => true,
|
||||
// // ]
|
||||
// //);
|
||||
// }
|
||||
|
||||
public function testPutWarehouse()
|
||||
{
|
||||
$response = $this->json('PUT', '/api/warehouse/6', [
|
||||
|
||||
'address'=> '2g',
|
||||
'city'=>'cj ',
|
||||
'zip'=>' 123',
|
||||
'state' =>' sl',
|
||||
'contact_person' =>'tuytguy',
|
||||
'contact_person_no' =>'1212122 ',
|
||||
'branch'=>'yap ',
|
||||
'country' =>' ba',
|
||||
'company_id' =>'1212 '
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
]);
|
||||
|
||||
$response
|
||||
->assertStatus(200);
|
||||
// ->assertJson([
|
||||
//
|
||||
// ]
|
||||
// );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user