Все отлично работает на localhost, но при переносе на сервер godaddy live (cpanel) я продолжаю получать эту ошибку (неопределенное смещение: 0) в моем блэйд-представлении
Я протестировал приложение на своем локальном хосте с использованием XAMPPработает PHP 7.2.12, и он работает очень хорошо, но теперь я переместил его на godaddy cpanel, работающий на PHP 7.3, и он продолжает выдавать мне эту ошибку
// Это мой Route Route :: get ('/ разговор','DoctorsController @ Conversations');
// Это открытая функция моего контроллера. Conversations (Request $ request) {
//authenticate user
if($request->us == 'guest'){
return redirect()->intended('login');
}else{
$unread=DB::table('messaging')
->where([
['Reciever', Auth::user()->id],
['ReadStatus', '=', '']
])
->get();
$pending=$unread->count();
//retrieve previous chat;
$conversations=DB::table('messaging')
->where('Sender', Auth::user()->id)
->orWhere('Reciever', Auth::user()->id)
->groupBy('Sender')
->orderBy('ReadStatus', 'asc')
->get();
//retrieve profile of users in the previous chat
$profiles = array();
$read_status = array();
foreach($conversations as $conversation){
if($conversation->Sender == Auth::user()->id){
//check user role to know which database to query
$userRole=DB::table('role_user')
->where('user_id', $conversation->Reciever)
->get();
if($userRole[0]->role_id === 2){
#retrieve the sender details from doctors table
$profile=DB::table('doctors')
->where('doctor_id', $conversation->Reciever)
->get();
}else{
//retrieve the sender details from users table
$profile=DB::table('profiles')
->where('user_id', $conversation->Reciever)
->get();
}
if(in_array($profile, $profiles)){
}else{
array_push($profiles, $profile);
}
//retrieve the reciever details
}else if($conversation->Reciever == Auth::user()->id){
//check user role to know which database to query
$userRole=DB::table('role_user')
->where('user_id', $conversation->Sender)
->get();
if($userRole[0]->role_id === 2){
$profile=DB::table('doctors')
->where('doctor_id', $conversation->Sender)
->get();
}else{
$profile=DB::table('profiles')
->where('user_id', $conversation->Sender)
->get();
}
//retrive unread chat;
$unreadconvers=DB::table('messaging')
->select('ReadStatus')
->where([
['Reciever', Auth::user()->id],
['Sender', $conversation->Sender],
['ReadStatus', '=', '']
])
->get();
if(in_array($profile, $profiles)){
}else{
$profile['unreads'] = $unreadconvers->count();
array_push($profiles, $profile);
//array_push($read_status, $unreadconvers->count());
}
}
$i++;
}
return view('conversations')->with(['profile'=>$profiles, 'pending'=>$pending, 'unreads'=>$read_status]);
//return to the conversation blade
}
}
// Это мой шаблон Blade @foreach ($ profile as$ profile)
<div class="col-md-4 element-animate">
<div class="media d-block media-custom text-center">
<img src= "{{ URL::to(isset($profile[0]->image) ? $profile[0]->image : '../img/user.png') }}" alt="Image Placeholder" class="img-fluid img-fluid-doctors">
<div class="media-body">
<a href="{{ isset($profile[0]->doctor_id) ? url('/chat-doctor?db='.$profile[0]->doctor_id) : url('/chat-doctor?us='.$profile[0]->user_id) }}" class="envelop"><i class="far fa-envelope"></i><span class="unread">{{ isset($profile['unreads']) ? $profile['unreads'] : 0 }}</span>
<h3 class="mt-0 text-black">{{ $profile[0]->name }}</h3>
</a>
</div>
</div>
</div>
@endforeach
Ожидается, что на контроллере этот код извлечет все сообщения из базы данных, ссылающиеся на вошедшего в систему пользователя, как отправленные, так и полученные, сохранит их с помощью массива и отобразит их на блейдешаблон зацикливается на каждом массиве.
В настоящее время это то, что он делает на локальном хосте, но на живом сервере я получаю это сообщение об ошибке Undefined offset: 0 (Просмотр: /resources/views/conversations.blade.php)