added api for tracking
This commit is contained in:
57
app/Http/Controllers/ApiController.php
Normal file
57
app/Http/Controllers/ApiController.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ApiModel;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
|
||||
class ApiController extends Controller
|
||||
{
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
$ApiModel = new ApiModel;
|
||||
$post = $request->all();
|
||||
$response = $ApiModel->loginProductionUser($post['username'], $post['password']);
|
||||
if (!$response) {
|
||||
return response()->json(['status' => false, 'message' => "Invalid user"], 401);
|
||||
}
|
||||
|
||||
return response()->json(['status' => true, 'data' => $response[0]], 200);
|
||||
}
|
||||
|
||||
public function insert(Request $request)
|
||||
{
|
||||
$ApiModel = new ApiModel;
|
||||
$post = $request->json()->all();
|
||||
|
||||
$data = array(
|
||||
"StepId" => $post['StepId'],
|
||||
"ScannedBy" => $post['ScannedBy'],
|
||||
"InvoiceNumber" => $post['invoice'],
|
||||
"Timezone" => $post['timezone'],
|
||||
"TimezoneOffset" => date('H:i:s',strtotime($post['timezoneOffset'])),
|
||||
"DeviceId" =>$post['deviceId'],
|
||||
"created_at" => date('Y-m-d H:i:s', strtotime($post['datetime']))
|
||||
);
|
||||
$response = $ApiModel->insertTracking($data);
|
||||
if (!$response) {
|
||||
return response()->json(['status' => false, 'message' => "Something went wrong."], 401);
|
||||
}
|
||||
|
||||
return response()->json(['status' => true, 'message' => 'Successfully updated.'], 201);
|
||||
}
|
||||
|
||||
public function getTrackingStatus()
|
||||
{
|
||||
$ApiModel = new ApiModel;
|
||||
$invoice = Input::get('invoice');
|
||||
$response = $ApiModel->getTrackingStatus($invoice);
|
||||
return response()->json(['status' => true, 'data' => $response], 200);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ use Illuminate\Http\Request;
|
||||
use App\Models\MainModel;
|
||||
// use Illuminate\Support\Facades\Request;
|
||||
use Analytics;
|
||||
use Session;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
|
||||
class MainController extends Controller {
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ use Illuminate\Http\Request;
|
||||
use Netshell\Paypal\Facades\Paypal;
|
||||
use App\Models\teamstore\TeamStoreModel;
|
||||
use App\Models\user\UserModel;
|
||||
use App\Models\ApiModel;
|
||||
use App\Models\paypal\PayPalModel;
|
||||
// use Auth;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@@ -19,7 +20,6 @@ use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
|
||||
|
||||
class PaypalController extends Controller
|
||||
{
|
||||
|
||||
@@ -74,8 +74,6 @@ class PaypalController extends Controller
|
||||
$payer = PayPal::Payer();
|
||||
$payer->setPaymentMethod('paypal');
|
||||
|
||||
|
||||
|
||||
$m = new TeamStoreModel;
|
||||
$paypal_model = new PayPalModel;
|
||||
$last_id = $paypal_model->getLastIdPaymentDetails();
|
||||
@@ -382,6 +380,17 @@ class PaypalController extends Controller
|
||||
});
|
||||
// end email sending
|
||||
|
||||
|
||||
$insertTracking = array(
|
||||
"StepId" => 1,
|
||||
"ScannedBy" => 1,
|
||||
"InvoiceNumber" => $invoice_number,
|
||||
"created_at" => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
$ApiModel = new ApiModel;
|
||||
$ApiModel->insertTracking($insertTracking);
|
||||
|
||||
$request->session()->forget('cartkey'); // clear session for cartkey
|
||||
|
||||
// redirect to thank you page.
|
||||
|
||||
Reference in New Issue
Block a user