Кажется, у меня возникла очень трудная проблема после того, как я настроил многопользовательскую конфигурацию для администратора и продавца. Но на самом деле, я действительно не знаю, что вызвало эту проблему. Из-за этого я действительно ценю вашу скромность, чтобы помочь мне в этом.
Когда пытались получить доступ к этому маршруту:
продавец / транзакция / создание / руководство (на страницах продавца)
или
транзакция / создание / руководство (на страницах администратора)
Я получаю неопределенное смещение 0, потому что не могу получить данные, которые предоставляет API. Эта ошибка произошла только после того, как я перезагрузил страницу несколько раз (может быть, 2 или 3 раза перезагрузить). И после того, как я снова перезагрузил, ошибка как-то исправилась, и позже ... это произошло снова после перезагрузки страниц: (
В Laravel Bug Review, это показывает, что ошибка привела к
Подсветка \ Foundation \ Http \ Kernel handle
Изображение [1]: https://i.stack.imgur.com/ldaII.png [Файл, который получает ошибку неопределенного смещения 0]
Изображение [2]: https://i.stack.imgur.com/GVFRS.png [Край файла ошибки]
На ваш взгляд, я использую Laravel 5.8.35. И это функция в файле с именем SalesPersonController. php, в которой я получаю неопределенную ошибку смещения 0.
class SalesPersonController extends Controller
{
use AuthorizesRequests, ValidatesRequests;
public function Index(){
if(isset($id)){
$search['value'] = $id;
$search['type'] = "exact";
$search['payment_type'] = $payment_type;
$user = Myhelper::post('transaction/get_customer', $search);
// return $user;
if(isset($user['status'])&&($user['status']==='success')){
$data['user'] = $user['result'];
}else{
$data['user'] = [];
}
// return $data['user'];
if($data['user'] == []){
$message = ['Customer '.$id.' tidak ditemukan'];
session(['error'=> $message]);
if (isset($payment_type) && $payment_type == 'manual') {
return redirect('salesperson/transaction/create/manual');
}else{
return redirect('/transaction/create');
}
}elseif( isset($data['user']['transaction'] ) ){
// && $data['user']['transaction'] !=[] && ($data['user']['transaction']['payment_type'] == 'manual' && $data['user']['transaction']['payment_status'] == 'success')
$midtrans = false;
$success = false;
$receipt = '';
foreach ($data['user']['transaction'] as $item) {
if($item['payment_status'] == 'success'){
$receipt = $item['receipt_number'];
$success = true;
break;
}elseif($item['payment_type'] == "midtrans"){
$midtrans = true;
$receipt = $item['receipt_number'];
break;
}
}
if ($success) {
$message = ['Transaksi untuk customer "'.$data['user']['name'].'" dengan email "'.$data['user']['email'].'" dan nomor "'.$data['user']['phone'].'" sudah terkonfirmasi'];
session(['success'=> $message]);
return redirect('/transaction/detail/'.$receipt);
}elseif($midtrans){
$message = ['Transaksi untuk customer "'.$data['user']['name'].'" dengan email "'.$data['user']['email'].'" dan nomor "'.$data['user']['phone'].'" sudah menggunakan pembayaran midtrans'];
session(['error'=> $message]);
return redirect('/transaction/detail/'.$receipt);
}
}
// return $user;
}else{
$request = [
'bank' => 1,
'bank_method' => 1,
'manual_payment' => 1,
'city' => 1,
'price' => 1,
'today' => 1,
'salesperson' => 1
];
$data = MyHelper::post('transaction/get_master_data', $request);
}
$product = MyHelper::get('product');
$all_product = MyHelper::get('product/all');
// dd($product['status']);
if((isset($product['status'])&&($product['status'] ==='success')) && (isset($all_product['status'])&&($all_product['status'] ==='success'))){
$data['product'] = $product['result'];
$data['all_product'] = $all_product['result'];
}else{
$data['product']= [];
$data['all_product'] = [];
}
// dd($data['product']);
// dd($data['all_product']);
$enumProduct = MyHelper::get('product/get_enum_data');
if(isset($enumProduct['status']) && ($enumProduct['status']==='success')){
$data['enum_product'] = $enumProduct['result'];
}else{
$data['enum_product'] = [];
}
// dd($data['enum_product']);exit;
$data['aligner'] = [];
$data['aligner_2'] = [];
$data['non_aligner'] = [];
$data['full_aligner'] = [];
$data['full_aligner_2'] = [];
$count1 = 0; $count2 = 0; $count3 = 0; $count4 = 0; $count5 = 0;
foreach($data['all_product'] as $product2){
if($product2['tipe'] === $data['enum_product']['tipe'][0]){
$data['aligner'][$count1] = $product2;
$count1++;
}else if($product2['tipe'] === $data['enum_product']['tipe'][1]){
$data['aligner_2'][$count2] = $product2;
$count2++;
}else if($product2['tipe'] === $data['enum_product']['tipe'][2]){
$data['non_aligner'][$count3] = $product2;
$count3++;
}else if($product2['tipe'] === $data['enum_product']['tipe'][3]){
$data['full_aligner'][$count4] = $product2;
$count4++;
}else{
$data['full_aligner_2'][$count5] = $product2;
$count5++;
}
}
$data['subtotal_service']['aligner'] = $this->getSubTotalService($data['aligner'][0]['id_product'], 'default');
$data['subtotal_service']['aligner_2'] = $this->getSubTotalService($data['aligner_2'][0]['id_product'], 'default');
$data['subtotal_service']['non_aligner'] = $this->getSubTotalService($data['non_aligner'][0]['id_product'], 'default');
$data['subtotal_service']['full_aligner'] = $this->getSubTotalService($data['full_aligner'][0]['id_product'], 'default');
$data['subtotal_service']['full_aligner_2'] = $this->getSubTotalService($data['full_aligner_2'][0]['id_product'], 'default');
$data['default_harga'] = 0;
for($i = 0; $i < sizeof($data['full_aligner']); $i++){
$data['default_harga'] = $data['default_harga'] + $data['full_aligner'][$i]['harga'];
$data['default_ppn_status'] = $data['full_aligner'][$i]['ppn_status'];
}
$data['default_product'] = $data['enum_product']['tipe'][3];
$data['default_harga_2'] = 0;
for($i = 0; $i < sizeof($data['full_aligner_2']); $i++){
$data['default_harga_2'] = $data['default_harga_2'] + $data['full_aligner_2'][$i]['harga'];
$data['default_ppn_status_2'] = $data['full_aligner_2'][$i]['ppn_status'];
}
$data['default_product_2'] = $data['enum_product']['tipe'][4];
$data['date'] = Date('Y-m-d H:i:s');
$data['payment_type'] = "manual";
if (isset($data['today'])) {
$data['today'] = date('d/M/Y',strtotime($data['today']));
}
return view('transaction::create_transaction2', $data);
}
И, наконец, вот мои маршруты в сети. php (Backend View) и api. php (API)
<?php
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
*/
Route::group(['middleware'=>'validate_session', 'prefix'=>'transaction'], function() {
Route::get('tests/{type}/{receipt}', 'TransactionController@tests');
Route::get('getSubTotalService/{product}','TransactionController@getSubTotalService'); Route::get('getTransactionParent/{prd_type}/{user_phone}/{email}','TransactionController@getTransactionParent');
Route::get('getAlignerCicilan/{user_phone}','TransactionController@getAlignerCicilan');
Route::get('getDiscount/{id_transaction}','TransactionController@getDiscount');
Route::get('getProduct/{product_code}','TransactionController@getProduct');
Route::group(['middleware' => ['validate_session']], function(){
Route::middleware('feature_control:18')->get('create/manual/{id}', ['uses' => 'TransactionController@create', 'payment_type' => 'manual']);
Route::middleware('feature_control:18')->get('create/manual', ['uses' => 'TransactionController@create', 'payment_type' => 'manual']);
Route::middleware('feature_control:18')->get('create/{id}', ['uses' => 'TransactionController@create', 'payment_type' => 'midtrans']);
Route::middleware('feature_control:18')->get('create', ['uses' => 'TransactionController@create', 'payment_type' => 'midtrans']);
});
});
Route::group(['middleware'=>'sales_person', 'prefix'=>'salesperson/transaction'], function(){
Route::get('getSubTotalService/{product}','TransactionController@getSubTotalService');Route::get('getTransactionParent/{prd_type}/{user_phone}/{email}','TransactionController@getTransacti onParent');
Route::get('getAlignerCicilan/{user_phone}','TransactionController@getAlignerCicilan');
Route::get('getDiscount/{id_transaction}','TransactionController@getDiscount');
Route::get('getProduct/{product_code}','TransactionController@getProduct');
Route::post('getPromo', 'TransactionController@getPromo');
});
Маршруты API
<?php
use Illuminate\Http\Request;
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
Route::group(['prefix' => 'transaction'], function () {
Route::get('getAlignerCicilan/{user_phone}','TransactionController@getAlignerCicilan');
Route::get('getDiscount/{id_transaction}','TransactionController@getDiscount');
Route::get('getProduct/{product_code}','TransactionController@getProduct')
});
Route::middleware('auth:api')->get('/transaction', function (Request $request) {
return $request->user();
});
Route::group(['prefix' => 'transaction', 'middleware' => 'auth:api' ], function () {
Route::post('update/{id}','TransactionController@update');
Route::get('edit/{receipt}','TransactionController@edit');
Route::get('detail/{receipt}','TransactionController@detail');
Route::get('delete/{receipt}','TransactionController@delete');
Route::get('show/{id}','TransactionController@show');
Route::get('/Report','DailyController@daily_report');
Route::post('confirm_transaction','TransactionController@confirm_transaction');
Route::post('storeApiTransactionManual','ApiTransactionManualController@store');
Route::post('update_shipping','TransactionController@update_shipping');
Route::post('store_transaction_user','TransactionController@store_transaction_user');
Route::post('upload_images','TransactionController@upload_images');
Route::post('delete_images','TransactionController@delete_images');
Route::post('update_note','TransactionController@update_note');
Route::post('update_aligner','TransactionController@update_aligner');
Route::post('send_video_notification','TransactionController@send_video_notification');
Route::post('confirm_complete','TransactionController@confirm_complete');
Route::post('update_contact','TransactionController@update_contact');
});
Route::group(['prefix' => 'transaction'], function () {
Route::post('store','TransactionController@store');
Route::post('storeOrder','TransactionController@storeOrder');
Route::get('getPromo/{code}/{id_product}','TransactionController@getPromoByCode');
Route::get('get_default_product','TransactionController@getDefaultProduct');
Route::post('get_master_data','TransactionController@post_master_data');
Route::get('getPrice','TransactionController@getPrice');
Route::get('getPrice/{product_slug}','TransactionController@getPriceProduct');
Route::post('orderConfirm','TransactionController@orderConfirm');
Route::post('notification','TransactionController@midtransNotif')->middleware('log_request');
Route::get('test','TransactionController@test');
Route::get('midtrans/{id_transaction}','TransactionController@midtrans_token')- >middleware('log_request');
Route::get('kredivo/{receipt_number}','TransactionController@kredivo_token');
Route::get('payment/{receipt_number}','TransactionController@midtrans_link');
Route::get('getBank','ApiTransactionManualController@getBank');
Route::get('getBankMethod','ApiTransactionManualController@getBankMethod');
Route::get('getManualPayment','ApiTransactionManualController@getManualPayment');
Route::post('storeTransactionManual','ApiTransactionManualController@store');
Route::post('emailCheck','ApiTransactionManualController@emailCheck');
Route::post('getUserEmail','ApiTransactionManualController@getUserEmail');
Route::post('getUserEmailbyOrderId','ApiTransactionManualController@getUserEmailByOrderId');
Route::post('storeBook/','ApiTransactionManualController@storeBook');
Route::post('get_customer','TransactionController@get_customer');
Route::get('get_waiting_counter','TransactionController@get_waiting_counter');
});
Route::group(['prefix'=>'salesperson', 'middleware'=>'auth:salesperson'],function(){
Route::post('transaction/store_transaction_user','TransactionController@store_transaction_user');
});