mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim-api.git
synced 2026-08-19 04:24:01 +00:00
Merge branch 'asif/warehouses' into 'master'
: warehouse and contacts for freight forwarder See merge request CIEFWorldwideSdnBhd/izyim-api!14
This commit is contained in:
@@ -12,3 +12,4 @@ Homestead.yaml
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
.env
|
||||
.lock
|
||||
|
||||
+31
-3
@@ -6,10 +6,26 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
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 = [];
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
'company_profile',
|
||||
'reg_cert',
|
||||
'company_name',
|
||||
'registration_no',
|
||||
'tax_no',
|
||||
'tel_no',
|
||||
'fax',
|
||||
'address',
|
||||
'city',
|
||||
'postcode',
|
||||
'state',
|
||||
'country',
|
||||
'contact_person',
|
||||
'user_id',
|
||||
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\User');
|
||||
@@ -20,4 +36,16 @@ class Company extends Model
|
||||
return $this->hasMany('App\Deliveryinfo');
|
||||
|
||||
}
|
||||
|
||||
public function warehouse() {
|
||||
|
||||
return $this->hasMany('App\Warehouse');
|
||||
|
||||
}
|
||||
|
||||
public function contact() {
|
||||
|
||||
return $this->hasMany('App\Contact');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Contact extends Model
|
||||
{
|
||||
protected $fillable = ['company_id'];
|
||||
|
||||
public function user() {
|
||||
|
||||
return $this->belongsTo(App\User);
|
||||
|
||||
}
|
||||
|
||||
public function company(){
|
||||
|
||||
return $this->belongsTo(App\Company);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,9 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Deliveryinfo extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'branch',
|
||||
protected $fillable = [
|
||||
'deli_info',
|
||||
'address',
|
||||
'city',
|
||||
@@ -20,10 +18,10 @@ class Deliveryinfo extends Model
|
||||
'com_id'
|
||||
];
|
||||
|
||||
public function company() {
|
||||
public function company(){
|
||||
|
||||
return $this->belongsTo('App\Company');
|
||||
|
||||
}
|
||||
return $this->belongsTo(App\Company);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class AuthController extends Controller
|
||||
$token = mt_rand(0000,9999);
|
||||
|
||||
// for testing
|
||||
if($request->phone == '0123456789'){
|
||||
if($request->phone == '0143499252'){
|
||||
$token = "1234";
|
||||
}
|
||||
|
||||
@@ -159,6 +159,12 @@ class AuthController extends Controller
|
||||
|
||||
return response()->json(['success'=> true, 'message'=> 'Profile updated.'], 200);
|
||||
}
|
||||
public function show()
|
||||
{
|
||||
return response()->json(['user' => Auth::user()]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@@ -294,4 +300,6 @@ class AuthController extends Controller
|
||||
'success' => false, 'data'=> ['message'=> 'Invalid token or email or expired code']
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,27 @@ 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();
|
||||
|
||||
if($matchedTerms)
|
||||
{
|
||||
foreach ($matchedTerms as $key => $matchedTerm)
|
||||
{
|
||||
array_push($output, ['com_id'=> $matchedTerm->id, '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();
|
||||
@@ -31,14 +52,17 @@ class CompanyController extends Controller
|
||||
'state' => 'required',
|
||||
'country' => 'required',
|
||||
'contact_person' => 'required'
|
||||
];
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(), $rules);
|
||||
if($validator->fails()) {
|
||||
return response()->json(['success'=> false, 'error'=> 'All the fields are required'], 400);
|
||||
//return response()->json(['success'=> false, 'error'=> $validator->messages()], 400);
|
||||
$validator = Validator::make($request->all(), $rules);
|
||||
if($validator->fails()) {
|
||||
return response()->json(['success'=> false, 'error'=> 'All the fields are required'], 400);
|
||||
//return response()->json(['success'=> false, 'error'=> $validator->messages()], 400);
|
||||
}
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$company->company_name=$request->input('company_name');
|
||||
$company->registration_no=$request->input('registration_no');
|
||||
$company->tax_no=$request->input('tax_no');
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Contact;
|
||||
use App\Company;
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
|
||||
class ContactController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$contacts = Contact::where('user_id', Auth::user()->id)->where('id', $id)->get();
|
||||
|
||||
if (!$contacts)
|
||||
{
|
||||
return response()->json(['message'=>'Access Denied!'], 404);
|
||||
}
|
||||
|
||||
return response()->json($contacts, 200);
|
||||
}
|
||||
|
||||
public function sendRequest(Request $request)
|
||||
{
|
||||
$user = Auth::user();
|
||||
$com_id = $request->input('com_id');
|
||||
|
||||
// query to find company asisng to $company
|
||||
$company = Company::find($com_id);
|
||||
|
||||
// get user from session
|
||||
$request->user();
|
||||
$user = $request->user();
|
||||
|
||||
// prepare query
|
||||
$contact = new Contact();
|
||||
$contact->com_id = $company->id;
|
||||
$contact->user_id = $user->id;
|
||||
$contact->save();
|
||||
|
||||
return response()->json($contact, 201);
|
||||
}
|
||||
|
||||
public function acceptRequest(Request $request, $id)
|
||||
{
|
||||
$contact = Contact::where('com_id', Auth::user()->company())->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);
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$contact = Contact::where('com_id', Auth::user()->company())->where('id', $id)->first();
|
||||
|
||||
if (!$contact)
|
||||
{
|
||||
return response()->json(['message'=>'Access Denied!'], 404);
|
||||
}
|
||||
|
||||
$contact->delete($id);
|
||||
|
||||
return response()->json($contact, 204);
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,16 @@ namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Deliveryinfo;
|
||||
use App\User;
|
||||
use App\Company;
|
||||
use Auth;
|
||||
|
||||
class DeliveryinfoController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$deliveryinfo = Deliveryinfo::where('com_id', Auth::user()->company())->get();
|
||||
return response()->json($deliveryinfo, 200);
|
||||
$deliveryinfos = Deliveryinfo::orderBy('id', 'desc')->get();
|
||||
return response()->json($deliveryinfos, 200);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -22,7 +24,8 @@ class DeliveryinfoController extends Controller
|
||||
*/
|
||||
public function show(Deliveryinfo $id)
|
||||
{
|
||||
$deliveryinfo = Deliveryinfo::where('com_id', Auth::user()->company())->where('id', $id)->firstOrFail();
|
||||
//$deliveryinfo = Deliveryinfo::where('com_id', Auth::user()->company())->where('id', $id)->first();
|
||||
$deliveryinfo = Deliveryinfo::find($id)->first();
|
||||
return response()->json($deliveryinfo, 200);
|
||||
}
|
||||
|
||||
@@ -37,7 +40,6 @@ class DeliveryinfoController extends Controller
|
||||
$user = Auth::user();
|
||||
|
||||
$deliveryinfo = new Deliveryinfo;
|
||||
$deliveryinfo->branch = $request->input('branch');
|
||||
$deliveryinfo->deli_info = $request->input('deli_info');
|
||||
$deliveryinfo->address = $request->input('address');
|
||||
$deliveryinfo->city = $request->input('city');
|
||||
@@ -46,7 +48,7 @@ class DeliveryinfoController extends Controller
|
||||
$deliveryinfo->country = $request->input('country');
|
||||
$deliveryinfo->contact_person = $request->input('contact_person');
|
||||
$deliveryinfo->contact_person_no = $request->input('contact_person_no');
|
||||
$deliveryinfo->com_id = $user->company();
|
||||
$deliveryinfo->com_id = $user->company()->first()->id;
|
||||
$deliveryinfo->save();
|
||||
|
||||
return response()->json(['deliveryinfo'=>$deliveryinfo],201);
|
||||
@@ -61,14 +63,15 @@ class DeliveryinfoController extends Controller
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$deliveryinfo = Deliveryinfo::where('com_id', Auth::user()->company())->where('id', $id)->firstOrFail();
|
||||
|
||||
$user = Auth::user();
|
||||
|
||||
//$deliveryinfo = Deliveryinfo::where('com_id', Auth::user()->company())->where('id', $id)->firstOrFail();
|
||||
$deliveryinfo = Deliveryinfo::find($id);
|
||||
if (!$deliveryinfo)
|
||||
{
|
||||
return response()->json(['message'=>'Access Denied!'], 404);
|
||||
}
|
||||
|
||||
$deliveryinfo->branch = $request->input('branch');
|
||||
|
||||
$deliveryinfo->deli_info = $request->input('deli_info');
|
||||
$deliveryinfo->address = $request->input('address');
|
||||
$deliveryinfo->city = $request->input('city');
|
||||
@@ -77,7 +80,7 @@ class DeliveryinfoController extends Controller
|
||||
$deliveryinfo->country = $request->input('country');
|
||||
$deliveryinfo->contact_person = $request->input('contact_person');
|
||||
$deliveryinfo->contact_person_no = $request->input('contact_person_no');
|
||||
$deliveryinfo->com_id = $user->company();
|
||||
$deliveryinfo->com_id = $user->company()->first()->id;
|
||||
$deliveryinfo->save();
|
||||
|
||||
return response()->json(['deliveryinfo'=>$deliveryinfo],200);
|
||||
@@ -92,8 +95,8 @@ class DeliveryinfoController extends Controller
|
||||
*/
|
||||
public function destroy(Deliveryinfo $id)
|
||||
{
|
||||
$deliveryinfo = Deliveryinfo::where('com_id', Auth::user()->company())->where('id', $id)->firstOrFail();
|
||||
|
||||
//$deliveryinfo = Deliveryinfo::where('com_id', Auth::user()->company())->where('id', $id)->firstOrFail();
|
||||
$deliveryinfo = Deliveryinfo::find($id)->first();
|
||||
if (!$deliveryinfo)
|
||||
{
|
||||
return response()->json(['message'=>'Access Denied!'], 404);
|
||||
@@ -101,6 +104,6 @@ class DeliveryinfoController extends Controller
|
||||
|
||||
$deliveryinfo->delete($id);
|
||||
|
||||
return response()->json($deliveryinfo, 204);
|
||||
return response()->json(['deliveryinfo'=>$deliveryinfo], 204);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Contact;
|
||||
use App\Warehouse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class WarehouseController extends Controller
|
||||
{
|
||||
/**
|
||||
* list all the warehouse from user's contact's where user is freight forwarder
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$warehouses = Warehouse::where('com_id', Auth::user()->company())->get();
|
||||
|
||||
if (!$warehouses)
|
||||
{
|
||||
return response()->json(['message'=>'Access Denied!'], 404);
|
||||
}
|
||||
|
||||
//$warehouse = Warehouse::all();
|
||||
|
||||
return response()->json($warehouses, 200);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display warehouse list from freight forwarder. can list the warehouse if it is from the freight forwarder
|
||||
* need to do DB query
|
||||
* show all the warehouse that belongs to the user company
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$warehouses = DB::table('warehouses')
|
||||
->select('id', 'address', 'city', 'zip', 'state', 'contact_person', 'contact_person_no', 'branch', 'country', 'com_id')
|
||||
->where('com_id', Auth::user()->company())
|
||||
->get();
|
||||
|
||||
if (!$warehouses)
|
||||
{
|
||||
return response()->json(['message'=>'Access Denied!'], 404);
|
||||
}
|
||||
|
||||
return response()->json($warehouse, 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a new warehouse.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
$warehouse = new Warehouse;
|
||||
$warehouse->address = $request->input('address');
|
||||
$warehouse->city = $request->input('city');
|
||||
$warehouse->zip = $request->input('zip');
|
||||
$warehouse->state = $request->input('state');
|
||||
$warehouse->contact_person = $request->input('contact_person');
|
||||
$warehouse->contact_person_no = $request->input('contact_person_no');
|
||||
$warehouse->branch = $request->input('branch');
|
||||
$warehouse->country = $request->input('country');
|
||||
$warehouse->com_id = $user->company();
|
||||
$warehouse->save();
|
||||
|
||||
return response()->json($warehouse, 201);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update warehouse.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
|
||||
$warehouse = Warehouse::where('com_id', Auth::user()->company())->where('id', $id)->firstOrFail();
|
||||
|
||||
if (!$warehouse)
|
||||
{
|
||||
return response()->json(['message'=>'Access Denied!'], 404);
|
||||
}
|
||||
|
||||
$warehouse->address = $request->input('address');
|
||||
$warehouse->city = $request->input('city');
|
||||
$warehouse->zip = $request->input('zip');
|
||||
$warehouse->state = $request->input('state');
|
||||
$warehouse->contact_person = $request->input('contact_person');
|
||||
$warehouse->contact_person_no = $request->input('contact_person_no');
|
||||
$warehouse->branch = $request->input('branch');
|
||||
$warehouse->country = $request->input('country');
|
||||
$warehouse->com_id = $user->company();
|
||||
$warehouse->save();
|
||||
|
||||
return response()->json(['warehouse'=>$warehouse],200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the warehouse.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Warehouse $id)
|
||||
{
|
||||
$warehouse = Warehouse::where('com_id', Auth::user()->company())->where('id', $id)->firstOrFail();
|
||||
|
||||
if (!$warehouse)
|
||||
{
|
||||
return response()->json(['message'=>'Access Denied!'], 404);
|
||||
}
|
||||
|
||||
$warehouse->delete($id);
|
||||
|
||||
return response()->json($warehouse, 204);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Warehouse extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
|
||||
'address',
|
||||
'city',
|
||||
'zip',
|
||||
'state',
|
||||
'contact_person',
|
||||
'contact_person_no',
|
||||
'branch',
|
||||
'country',
|
||||
'com_id'
|
||||
|
||||
];
|
||||
|
||||
public function company(){
|
||||
|
||||
return $this->belongsTo(App\Company);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"aloha/twilio": "^4.0",
|
||||
"doctrine/dbal": "~2.3",
|
||||
"doctrine/dbal": "^2.8",
|
||||
"fideloper/proxy": "^4.0",
|
||||
"intervention/image": "^2.4",
|
||||
"laravel/framework": "5.6.*",
|
||||
|
||||
Generated
+441
-552
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',
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(App\Contact::class, function (Faker $faker) {
|
||||
return [
|
||||
'user_id' => '1',
|
||||
'com_id' => '1',
|
||||
'status' => '1',
|
||||
];
|
||||
});
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateWarehousesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('warehouses', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('address');
|
||||
$table->string('city');
|
||||
$table->integer('zip');
|
||||
$table->string('state');
|
||||
$table->string('contact_person');
|
||||
$table->integer('contact_person_no');
|
||||
$table->string('branch');
|
||||
$table->string('country');
|
||||
$table->string('company_id');
|
||||
$table->timestamps();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('warehouses');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateContactsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('contacts', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->foreign('user_id')
|
||||
|
||||
->references('id')->on('users')
|
||||
->onDelete('cascade');
|
||||
//$table->unsignedInteger('user_id');
|
||||
|
||||
// $table->foreign('user_id')->references('id')->on('users');
|
||||
$table->integer('company_id')->unsigned();
|
||||
$table->foreign('company_id')
|
||||
->references('id')->on('companies')
|
||||
->onDelete('cascade');
|
||||
$table->Integer('status')->default('0');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('contacts');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddForeignKeyToWarehousesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('warehouses', function (Blueprint $table) {
|
||||
|
||||
$table->unsignedInteger('com_id');//FK wrn id
|
||||
$table->foreign('com_id')
|
||||
->references('id')->on('warehouses')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('warehouses', function (Blueprint $table) {
|
||||
//
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class DropAndAddCompanyId extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('contacts', function (Blueprint $table) {
|
||||
//
|
||||
$table->renameColumn('company_id', 'com_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('contacts', function (Blueprint $table) {
|
||||
$table->renameColumn('com_id', 'company_id');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class DropCompanyId extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('warehouses', function (Blueprint $table) {
|
||||
$table->dropColumn('company_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('warehouses', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class DropComIdForWarehousesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('warehouses', function (Blueprint $table) {
|
||||
|
||||
$table->dropForeign(['com_id']);
|
||||
$table->dropColumn('com_id');
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('warehouses', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class ChangeReferenceIdForWarehousesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('warehouses', function (Blueprint $table) {
|
||||
|
||||
$table->unsignedInteger('com_id');//FK wrn id
|
||||
$table->foreign('com_id')
|
||||
->references('id')->on('companies')
|
||||
->onDelete('cascade');
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('warehouses', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class RemoveBranchFromDeliveryinfos extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('deliveryinfos', function (Blueprint $table) {
|
||||
$table->dropColumn('branch');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('deliveryinfos', function (Blueprint $table) {
|
||||
$table->string('branch');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -12,12 +12,14 @@ class CompanySeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('companies')->truncate();
|
||||
//DB::table('companies')->truncate();
|
||||
DB::table('companies')->insert([
|
||||
'id' => '999',
|
||||
'company_profile'=>'testing',
|
||||
'reg_cert'=>'12345',
|
||||
'company_name'=>'testing',
|
||||
'registration_no'=>'testing',
|
||||
'tax_no'=>'testing',
|
||||
'registration_no'=>'12345',
|
||||
'tax_no'=>'12345',
|
||||
'tel_no'=>'12345',
|
||||
'fax'=>'12345',
|
||||
'address'=>'testing',
|
||||
@@ -28,7 +30,7 @@ class CompanySeeder extends Seeder
|
||||
'contact_person'=>'testing',
|
||||
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
||||
'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
||||
'user_id' => '2'
|
||||
'user_id' => '5'
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -12,5 +12,15 @@ class ContactSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('contacts')->insert([
|
||||
|
||||
'id' => '999',
|
||||
'user_id' => '2',
|
||||
'com_id' => '999',
|
||||
'status' => '1',
|
||||
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
||||
'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
||||
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@ class DatabaseSeeder extends Seeder
|
||||
{
|
||||
$this->call(LaratrustSeeder::class);
|
||||
$this->call(UsersTableSeeder::class);
|
||||
$this->call(DeliveryInfoSeeder::class);
|
||||
$this->call(CompanySeeder::class);
|
||||
$this->call(DeliveryInfoSeeder::class);
|
||||
$this->call(WarehouseSeeder::class);
|
||||
$this->call(ContactSeeder::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,16 +13,14 @@ class DeliveryInfoSeeder extends Seeder
|
||||
public function run()
|
||||
{
|
||||
DB::table('deliveryinfos')->insert([
|
||||
|
||||
'id' => '999',
|
||||
'branch' => 'Testing',
|
||||
'deli_info' => 'Testing',
|
||||
'address' => 'Testing',
|
||||
'city' => 'Test',
|
||||
|
||||
'deli_info' => 'testing',
|
||||
'address' => 'testing',
|
||||
'city' => 'testing',
|
||||
'postcode' => '12345',
|
||||
'state' => 'Testing',
|
||||
'country' => 'Testing',
|
||||
'contact_person' => 'Testing',
|
||||
'state' => 'testing',
|
||||
'country' => 'testing',
|
||||
'contact_person' => 'testing',
|
||||
'contact_person_no' => '12345',
|
||||
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
||||
'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class WarehouseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('warehouses')->insert([
|
||||
|
||||
'id' => '999',
|
||||
'address'=>'testing',
|
||||
'city'=>'testing',
|
||||
'zip'=>'12345',
|
||||
'state'=>'testing',
|
||||
'contact_person'=>'testing',
|
||||
'contact_person_no'=>'12345',
|
||||
'branch'=>'testing',
|
||||
'country'=>'testing',
|
||||
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
||||
'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
||||
'com_id' => '999'
|
||||
|
||||
]);
|
||||
}
|
||||
}
|
||||
+10
-19
@@ -1,20 +1,11 @@
|
||||
ARG MYSQL_VERSION=latest
|
||||
FROM mysql:${MYSQL_VERSION}
|
||||
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"]
|
||||
|
||||
LABEL maintainer="Mahmoud Zalt <mahmoud@zalt.me>"
|
||||
|
||||
#####################################
|
||||
# Set Timezone
|
||||
#####################################
|
||||
|
||||
ARG TZ=UTC
|
||||
ENV TZ ${TZ}
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
RUN chown -R mysql:root /var/lib/mysql/
|
||||
|
||||
COPY my.cnf /etc/mysql/conf.d/my.cnf
|
||||
|
||||
CMD ["mysqld"]
|
||||
|
||||
EXPOSE 3306
|
||||
|
||||
Generated
-13702
File diff suppressed because it is too large
Load Diff
Vendored
+10419
File diff suppressed because it is too large
Load Diff
+1086
-963
File diff suppressed because it is too large
Load Diff
Vendored
+47387
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"/js/app.js": "/js/app.js",
|
||||
"/css/app.css": "/css/app.css"
|
||||
}
|
||||
+112
-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="search_results" class="main-menu" style="background-color: #FFF">
|
||||
|
||||
</ul>
|
||||
<div class="form-divider"></div>
|
||||
</div>
|
||||
@@ -198,37 +84,121 @@
|
||||
|
||||
</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 id="companyname" 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 id="telno" 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 id="contactpers" 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";
|
||||
//var company_name, tel_no, contact_person;
|
||||
$('#search').on('keyup', function(){
|
||||
$('#search_results').empty();
|
||||
var ul, li, data;
|
||||
$.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++){
|
||||
$('#search_results').append('<li style="display: show;"> <a href="#" onclick="displayCompany(' + "'" + data[i].company_name + "'" + ',' + "'" + data[i].tel_no + "'" + ',' + "'" + data[i].contact_person + "'" + ',' + "'" + data[i].com_id + "'" + ')"> <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);
|
||||
}
|
||||
//$('#searchresults').show();
|
||||
},
|
||||
error:function(data){
|
||||
console.log(data);
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
//displayCompany.apply(this, data);
|
||||
function displayCompany(company_name, tel_no, contact_person, com_id){
|
||||
$('#companyname').text(company_name);
|
||||
$('#telno').text(tel_no);
|
||||
$('#contactpers').text(contact_person);
|
||||
|
||||
$('#formPopup5').show();
|
||||
$('#addContact').click(function() {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "api/contacts",
|
||||
headers: {"Authorization": 'Bearer' + localStorage.getItem('token')},
|
||||
data: {
|
||||
com_id: com_id,
|
||||
},
|
||||
success: function(data) {
|
||||
console.log(data);
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
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("searchresults");
|
||||
// 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>
|
||||
+58
-14
@@ -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,11 +19,33 @@ 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');
|
||||
// Route::get('test', function(){
|
||||
// return response()->json(['foo'=>'bar']);
|
||||
// });
|
||||
//});
|
||||
|
||||
Route :: post('/warehouse','WarehouseController@store');
|
||||
Route :: get('/warehouse/{war_id}','WarehouseController@show');
|
||||
Route :: put('/warehouse/{war_id}','WarehouseController@update');
|
||||
Route :: get('/warehouse','WarehouseController@index');
|
||||
|
||||
|
||||
|
||||
|
||||
//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');
|
||||
@@ -37,17 +53,45 @@ Route::group(['middleware' => ['jwt.auth']], function() {
|
||||
return response()->json(['user'=> $request->user()]);
|
||||
});
|
||||
|
||||
/*Delivery-Info in profile menu*/
|
||||
Route::get('/deliveryinfo','DeliveryinfoController@index');
|
||||
Route::get('/deliveryinfo/{com_id}','DeliveryinfoController@show');
|
||||
// Delivery-Info
|
||||
Route::get('/deliveryinfo/','DeliveryinfoController@index');
|
||||
Route::get('/deliveryinfo/{id}','DeliveryinfoController@show');
|
||||
Route::post('/deliveryinfo', 'DeliveryinfoController@store');
|
||||
Route::put('/deliveryinfo/{com_id}', 'DeliveryinfoController@update');
|
||||
Route::delete('/deliveryinfo/{com_id}', 'DeliveryinfoController@destroy');
|
||||
Route::put('/deliveryinfo/{id}', 'DeliveryinfoController@update');
|
||||
Route::delete('/deliveryinfo/{id}', 'DeliveryinfoController@destroy');
|
||||
|
||||
|
||||
|
||||
/* 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::post('/company/company_profile/', 'CompanyController@companyProfile');//upload company
|
||||
Route::post('/company/reg_cert/', 'CompanyController@regCert'); //upload registration
|
||||
|
||||
/* Contacts */
|
||||
Route::get('/company/search', 'CompanyController@search');
|
||||
Route :: post('/contacts','ContactController@sendRequest');
|
||||
Route::post('/contacts/{company_id}/request', 'ContactController@postApprove');
|
||||
Route :: delete('/contacts/{contacts_id}','ContactController@destroy');
|
||||
Route :: get('/contacts','ContactController@index');
|
||||
});
|
||||
|
||||
//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');
|
||||
|
||||
// Route::put('company/{}', function(Request $request, $productId) {
|
||||
// $product = Company::findOrFail($productId);
|
||||
// $product->update($request->all());
|
||||
// return $product;
|
||||
// });
|
||||
|
||||
// Route::put('company/{}', function(Request $request, $companyId) {
|
||||
// $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)
|
||||
|
||||
@@ -20,6 +20,7 @@ class DeliveryinfoTest extends TestCase
|
||||
{
|
||||
parent::setUp();
|
||||
Artisan::call('db:seed');
|
||||
|
||||
$this->user = factory(User::class)->create();
|
||||
$this->company = $this->user->each(function ($u) {
|
||||
factory(Company::class)->create([
|
||||
@@ -28,57 +29,57 @@ class DeliveryinfoTest extends TestCase
|
||||
});
|
||||
}
|
||||
|
||||
// TODO : those test is wrong, please redo later.
|
||||
// TODO : those test is wrong, please redo later.
|
||||
// REDO the test
|
||||
|
||||
// public function testCreate()
|
||||
// {
|
||||
public function testPost()
|
||||
{
|
||||
|
||||
// $response = $this->actingAs($this->company)
|
||||
// ->patchJson('/api/deliveryinfo', [
|
||||
$response = $this->actingAs($this->user)
|
||||
->postJson('/api/deliveryinfo', [
|
||||
|
||||
// 'branch' => 'Test',
|
||||
// 'deli_info' => 'Testing',
|
||||
// 'address' => 'Testing',
|
||||
// 'city' => 'Test',
|
||||
// 'postcode' => '12345',
|
||||
// 'state' => 'Testing',
|
||||
// 'country' => 'Testing',
|
||||
// 'contact_person' => 'Testing',
|
||||
// 'contact_person_no' => '12345'
|
||||
|
||||
// ]);
|
||||
'branch' => 'Testing',
|
||||
'deli_info' => 'Testing',
|
||||
'address' => 'Testing',
|
||||
'city' => 'Testing',
|
||||
'postcode' => '12345',
|
||||
'state' => 'Testing',
|
||||
'country' => 'Testing',
|
||||
'contact_person' => 'Testing',
|
||||
'contact_person_no' => '12345'
|
||||
|
||||
]);
|
||||
|
||||
// $response->assertStatus(201);
|
||||
// }
|
||||
$response->assertStatus(201);
|
||||
}
|
||||
|
||||
|
||||
// public function testPUT()
|
||||
// {
|
||||
public function testPut()
|
||||
{
|
||||
|
||||
// $response = $this->actingAs($this->company)
|
||||
// ->patchJson('/api/deliveryinfo', [
|
||||
$response = $this->actingAs($this->user)
|
||||
->patchJson('/api/deliveryinfo', [
|
||||
|
||||
// 'branch' => 'Test',
|
||||
// 'deli_info' => 'Testing',
|
||||
// 'address' => 'Testing',
|
||||
// 'city' => 'Test',
|
||||
// 'postcode' => '12345',
|
||||
// 'state' => 'Testing',
|
||||
// 'country' => 'Testing',
|
||||
// 'contact_person' => 'Testing',
|
||||
// 'contact_person_no' => '12345'
|
||||
'branch' => 'ChangedTesting',
|
||||
'deli_info' => 'Testing',
|
||||
'address' => 'Testing',
|
||||
'city' => 'Testing',
|
||||
'postcode' => '12345',
|
||||
'state' => 'Testing',
|
||||
'country' => 'Testing',
|
||||
'contact_person' => 'Testing',
|
||||
'contact_person_no' => '12345'
|
||||
|
||||
// ]);
|
||||
]);
|
||||
|
||||
// $response->assertStatus(200);
|
||||
// }
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
// public function testDELETE()
|
||||
// {
|
||||
// $response = $this->json('DELETE', '/api/deliveryinfo');
|
||||
public function testDELETE()
|
||||
{
|
||||
$response = $this->json('DELETE', '/api/deliveryinfo');
|
||||
|
||||
// $response->assertStatus(204);
|
||||
// }
|
||||
|
||||
|
||||
$response->assertStatus(204);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use App\User;
|
||||
use App\Company;
|
||||
use Artisan;
|
||||
|
||||
class WarehouseTest extends TestCase
|
||||
{
|
||||
protected $company;
|
||||
protected $user;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
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()
|
||||
{
|
||||
$response = $this->actingAs($this->user)
|
||||
->postJson('/api/warehouse', [
|
||||
|
||||
'address'=> 'Testing',
|
||||
'city'=>'Testing ',
|
||||
'zip'=>' Testing',
|
||||
'state' =>'Testing',
|
||||
'contact_person' =>'Testing ',
|
||||
'contact_person_no' =>'12345 ',
|
||||
'branch'=>'Testing ',
|
||||
'country' =>' Testing',
|
||||
'com_id' =>'99'
|
||||
|
||||
]);
|
||||
|
||||
$response->assertStatus(201);
|
||||
|
||||
}
|
||||
|
||||
public function testUpdate()
|
||||
{
|
||||
|
||||
$response = $this->actingAs($this->user)
|
||||
->patchJson('/api/warehouse', [
|
||||
|
||||
'address' => 'Changed Testing',
|
||||
'city' => 'Testing ',
|
||||
'zip' => ' Testing',
|
||||
'state' => 'Testing',
|
||||
'contact_person' => 'Testing ',
|
||||
'contact_person_no' => '12345 ',
|
||||
'branch' => 'Testing ',
|
||||
'country' => ' Testing',
|
||||
'com_id' => '99'
|
||||
|
||||
]);
|
||||
|
||||
$response->assertStatus(201);
|
||||
|
||||
}
|
||||
|
||||
public function testDelete()
|
||||
{
|
||||
$this->actingAs($this->user)
|
||||
->json('DELETE', '/api/so/99');
|
||||
|
||||
$response->assertStatus(204);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\ContactTest;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Artisan;
|
||||
use App\User;
|
||||
use App\Company;
|
||||
|
||||
class ContactTest extends TestCase
|
||||
{
|
||||
protected $company;
|
||||
protected $user;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
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()
|
||||
{
|
||||
$response = $this->actingAs($this->user)
|
||||
->postJson('/api/contact', [
|
||||
|
||||
'com_id' => '1',
|
||||
]);
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
}
|
||||
|
||||
public function testApproved()
|
||||
{
|
||||
$response = $this->actingAs($this->user)
|
||||
->postJson('/api/contact/1/', [
|
||||
'user_id' => '1',
|
||||
'com_id' => '1',
|
||||
'status' => '1',
|
||||
]);
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user