latest code

This commit is contained in:
abdul-wahab12345 2024-10-29 06:42:23 +00:00
parent 98b34a2959
commit e2285db816
10 changed files with 59898 additions and 60 deletions

View File

@ -6,6 +6,7 @@
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use App\Models\Company; use App\Models\Company;
use App\Models\CompanyMeta;
use App\Models\ChatGroup; use App\Models\ChatGroup;
use App\Models\Message; use App\Models\Message;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
@ -136,13 +137,24 @@ public function sendMessage(Request $request)
public function select_user($company_id){ public function select_user($company_id){
$companyUsers = get_company_users($company_id); $companyUsers = get_company_users($company_id);
//Get Max Number f Chats
$get_max_number_of_chats = CompanyMeta::where('company_id', $company_id)->where('key', 'max_number_of_chats_per_editor')->first();
if(!is_null($get_max_number_of_chats)){
$get_max_number_of_chats = $get_max_number_of_chats->value;
}else{
$get_max_number_of_chats = 5;
}
$selected = false; $selected = false;
foreach($companyUsers as $user){ foreach($companyUsers as $user){
$access = json_decode($user->access); $access = json_decode($user->access);
//Get Chat Groups
$chat_groups = ChatGroup::where('user_id', $user->user_id)->where('status', 'open')->count();
if(in_array('chat',$access)){ if(in_array('chat',$access) && $user->user->is_available == 1 && $chat_groups <= $get_max_number_of_chats){
$selected = $user; $selected = $user;
break; break;
} }
@ -166,14 +178,25 @@ public function getChatGroupsByCompany(Request $request)
return response()->json($chatGroups); return response()->json($chatGroups);
} }
public function getIpAdresses($companyId)
{
return CompanyMeta::where('company_id', $companyId)
->where('type', 'Chat Setting')
->where('key', 'ip_addresses')
->pluck('value')
->toArray();
}
public function checkChat(Request $request){ public function checkChat(Request $request){
$company_id = $request->company_id; $company_id = $request->company_id;
$domain = $request->domain; $domain = $request->domain;
$company = get_company('id',$company_id); $company = get_company('id',$company_id);
$ip_addresses = $this->getIpAdresses($company_id);
$ip = $_SERVER['REMOTE_ADDR']; $ip = $_SERVER['REMOTE_ADDR'];
if(in_array($ip, $ip_addresses)) {
// return response()->json(['status' => 'error', 'message' => $ip]); return response()->json(['status' => 'error', 'message' => 'this IP Address ' . $ip . ' has been blocked.']);
}
if($company){ if($company){
// Str::contains('This is my name', 'my') // Str::contains('This is my name', 'my')
@ -215,7 +238,7 @@ public function checkChat(Request $request){
}) : null; }) : null;
//Terms And Conditions //Terms And Conditions
$link_text = getChatSetting('link_text', $company_id) ? getChatSetting('link_text', $company_id)->value : null; $link_text = "https://kundesone.no/terms-and-conditions/$company_id";//getChatSetting('link_text', $company_id) ? getChatSetting('link_text', $company_id)->value : null;
$user = $this->select_user($company_id); $user = $this->select_user($company_id);

View File

@ -12,7 +12,8 @@ public function chatSetting()
$display_chats = CompanyMeta::where('key', 'Display Chat')->where('type', 'Chat Setting')->get(); $display_chats = CompanyMeta::where('key', 'Display Chat')->where('type', 'Chat Setting')->get();
$hide_chats = CompanyMeta::where('key', 'Hide Chat')->where('type', 'Chat Setting')->first(); $hide_chats = CompanyMeta::where('key', 'Hide Chat')->where('type', 'Chat Setting')->first();
$canned_responses = CompanyMeta::where('key', 'Chat Canned Responses')->where('type', 'Chat Setting')->get(); $canned_responses = CompanyMeta::where('key', 'Chat Canned Responses')->where('type', 'Chat Setting')->get();
return view('chat-setting', ['display_chats' => $display_chats, 'hide_chats' => $hide_chats, 'canned_responses' => $canned_responses]); $abuses = CompanyMeta::where('key', 'ip_addresses')->where('type', 'Chat Setting')->get();
return view('chat-setting', ['display_chats' => $display_chats, 'hide_chats' => $hide_chats, 'canned_responses' => $canned_responses, 'abuses' => $abuses]);
} }
public function storeFlowSetting(Request $request) public function storeFlowSetting(Request $request)
@ -299,10 +300,7 @@ public function blockIpAdresses(Request $request)
]); ]);
$companyId = getSelectedCompany(); $companyId = getSelectedCompany();
CompanyMeta::updateOrCreate([ CompanyMeta::create([
'key' => 'ip_addresses',
'company_id' => $companyId,
],[
'company_id' => $companyId, 'company_id' => $companyId,
'key' => 'ip_addresses', 'key' => 'ip_addresses',
'value' => $request->ip_addresses, 'value' => $request->ip_addresses,
@ -312,6 +310,14 @@ public function blockIpAdresses(Request $request)
return redirect()->back()->with('success', 'Chat Setting Updated Successfully'); return redirect()->back()->with('success', 'Chat Setting Updated Successfully');
} }
public function deleteBlockIpAdresses($id)
{
$get_ip_address = CompanyMeta::find($id);
$get_ip_address->delete();
return redirect()->back()->with('success', 'IP Address Deleted Successfully.');
}
public function companyTermsAndConditions($companyId) public function companyTermsAndConditions($companyId)
{ {
$link_text = getChatSetting('link_text', $companyId)->value; $link_text = getChatSetting('link_text', $companyId)->value;

59784
error_log

File diff suppressed because it is too large Load Diff

Binary file not shown.

BIN
public/images/close.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

@ -712,10 +712,7 @@ class="form-control input-reply-textarea message_when_chat_is_closed">{!! $messa
@csrf @csrf
<div class="dev-input-group dev-input-group-input-info"> <div class="dev-input-group dev-input-group-input-info">
<label>IP address *</label> <label>IP address *</label>
@php <input type="text" name="ip_addresses" placeholder="Enter here">
$ip_addresses = getChatSetting('ip_addresses');
@endphp
<input type="text" name="ip_addresses" placeholder="Enter here" value="{{ $ip_addresses->value ?? '' }}">
<div class="dev-input-info"> <div class="dev-input-info">
<img src="{{ asset('images/info.svg') }}" alt="info"> <img src="{{ asset('images/info.svg') }}" alt="info">
<span>A full or partial IP address. E.g. 127.0.0.1 or 127.0.0</span> <span>A full or partial IP address. E.g. 127.0.0.1 or 127.0.0</span>
@ -731,6 +728,29 @@ class="form-control input-reply-textarea message_when_chat_is_closed">{!! $messa
</form> </form>
</div> </div>
</div> </div>
<div class="dev-tabcontent-outers">
<div class="dev-title-row">
<h2>Canned responses</h2>
<div class="dev-users-boxs">
@if(count($abuses) > 0)
@foreach($abuses as $index => $value)
<div class="dev-users-box">
<div class="dev-box">
<h3>{{ $value->value }}</h3>
</div>
<!--<div class="dev-icon">-->
<!-- <img src="{{ asset('images/settingss.svg') }}" alt="">-->
<!--</div>-->
<div class="dev-icon">
<a style="cursor:pointer;" href="{{ route('delete.block.ip.addresses', $value->id) }}" class="delete-display-chat"><img src="{{ asset('images/binn.svg') }}" alt=""></a>
</div>
</div>
@endforeach
@endif
</div>
</div>
</div>
</div> </div>
<!-- --> <!-- -->
<div class="dev-tabcontent dev-tabcontent-canned"> <div class="dev-tabcontent dev-tabcontent-canned">

View File

@ -208,53 +208,53 @@ function updateStatusOptions(selectedFilter) {
<!--chat avialability ajax--> <!--chat avialability ajax-->
<script> <script>
$(document).ready(function() { $(document).ready(function() {
$('#toggleSwitch').on('change', function() { // $('#toggleSwitch').on('change', function() {
const isChecked = $(this).is(':checked'); // const isChecked = $(this).is(':checked');
if (isChecked) { // if (isChecked) {
// Call route when toggle is ON // // Call route when toggle is ON
$.ajax({ // $.ajax({
url: 'update/chat-availability', // url: 'update/chat-availability',
method: 'POST', // method: 'POST',
headers: { // headers: {
'X-CSRF-TOKEN': "{{ csrf_token() }}" // 'X-CSRF-TOKEN': "{{ csrf_token() }}"
}, // },
data: { // data: {
status: 'on' // status: 'on'
}, // },
success: function(response) { // success: function(response) {
console.log('Success:', response); // console.log('Success:', response);
if(response.success) { // if(response.success) {
toastr.success('Chat Availability Updated Successfully'); // toastr.success('Chat Availability Updated Successfully');
} // }
}, // },
error: function(xhr, status, error) { // error: function(xhr, status, error) {
console.error('Error:', error); // console.error('Error:', error);
} // }
}); // });
} else { // } else {
// Call route when toggle is OFF // // Call route when toggle is OFF
$.ajax({ // $.ajax({
url: 'update/chat-availability', // url: 'update/chat-availability',
method: 'POST', // method: 'POST',
headers: { // headers: {
'X-CSRF-TOKEN': "{{ csrf_token() }}" // 'X-CSRF-TOKEN': "{{ csrf_token() }}"
}, // },
data: { // data: {
status: 'off' // status: 'off'
}, // },
success: function(response) { // success: function(response) {
console.log('Success:', response); // console.log('Success:', response);
if(response.success) { // if(response.success) {
toastr.success('Chat Availability Updated Successfully'); // toastr.success('Chat Availability Updated Successfully');
} // }
}, // },
error: function(xhr, status, error) { // error: function(xhr, status, error) {
console.error('Error:', error); // console.error('Error:', error);
} // }
}); // });
} // }
}); // });
}); });
</script> </script>

View File

@ -95,7 +95,11 @@ class="side-bar-link bg-light-color d-flex align-items-center justify-content-be
<div class="profile-nav-row d-flex side-bar-link"> <div class="profile-nav-row d-flex side-bar-link">
<div class="profile-nav-box"> <div class="profile-nav-box">
<div class="img-box"><img src="{{ asset('images/user.png') }}" alt="User Image"></div> @if(!is_null(Auth::user()->profile_image))
<div class="img-box"><a href="{{route('profile')}}"><img style="height: 42px; width: 42px; border-radius: 50%" src="{{ url('' . Auth::user()->profile_image) }}" alt="User Image"></a></div>
@else
<div class="img-box"><img style="height: 42px; width: 42px; border-radius: 50%" src="{{ asset('dummy-image.jpg') }}" alt="User Image"></div>
@endif
</div> </div>
</div> </div>

View File

@ -107,6 +107,7 @@
Route::post('store/tags', [ChatSettingController::class, 'storeTags'])->name('store.tags'); Route::post('store/tags', [ChatSettingController::class, 'storeTags'])->name('store.tags');
Route::post('setting/all-chat', [ChatSettingController::class, 'settingAllChat'])->name('setting.all.chat'); Route::post('setting/all-chat', [ChatSettingController::class, 'settingAllChat'])->name('setting.all.chat');
Route::post('block/ip-addresses', [ChatSettingController::class, 'blockIpAdresses'])->name('block.ip.addresses'); Route::post('block/ip-addresses', [ChatSettingController::class, 'blockIpAdresses'])->name('block.ip.addresses');
Route::get('delete/block/ip-addresses/{id}', [ChatSettingController::class, 'deleteBlockIpAdresses'])->name('delete.block.ip.addresses');
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home'); Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
Route::post('logout', [LoginController::class, 'logout'])->name('logout'); Route::post('logout', [LoginController::class, 'logout'])->name('logout');