latest code
This commit is contained in:
parent
98b34a2959
commit
e2285db816
|
|
@ -6,6 +6,7 @@
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyMeta;
|
||||
use App\Models\ChatGroup;
|
||||
use App\Models\Message;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
|
@ -136,13 +137,24 @@ public function sendMessage(Request $request)
|
|||
|
||||
public function select_user($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;
|
||||
|
||||
foreach($companyUsers as $user){
|
||||
$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;
|
||||
break;
|
||||
}
|
||||
|
|
@ -166,14 +178,25 @@ public function getChatGroupsByCompany(Request $request)
|
|||
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){
|
||||
$company_id = $request->company_id;
|
||||
$domain = $request->domain;
|
||||
|
||||
$company = get_company('id',$company_id);
|
||||
$ip_addresses = $this->getIpAdresses($company_id);
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
// return response()->json(['status' => 'error', 'message' => $ip]);
|
||||
if(in_array($ip, $ip_addresses)) {
|
||||
return response()->json(['status' => 'error', 'message' => 'this IP Address ' . $ip . ' has been blocked.']);
|
||||
}
|
||||
|
||||
if($company){
|
||||
// Str::contains('This is my name', 'my')
|
||||
|
|
@ -215,7 +238,7 @@ public function checkChat(Request $request){
|
|||
}) : null;
|
||||
|
||||
//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);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ public function chatSetting()
|
|||
$display_chats = CompanyMeta::where('key', 'Display Chat')->where('type', 'Chat Setting')->get();
|
||||
$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();
|
||||
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)
|
||||
|
|
@ -299,10 +300,7 @@ public function blockIpAdresses(Request $request)
|
|||
]);
|
||||
|
||||
$companyId = getSelectedCompany();
|
||||
CompanyMeta::updateOrCreate([
|
||||
'key' => 'ip_addresses',
|
||||
'company_id' => $companyId,
|
||||
],[
|
||||
CompanyMeta::create([
|
||||
'company_id' => $companyId,
|
||||
'key' => 'ip_addresses',
|
||||
'value' => $request->ip_addresses,
|
||||
|
|
@ -312,6 +310,14 @@ public function blockIpAdresses(Request $request)
|
|||
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)
|
||||
{
|
||||
$link_text = getChatSetting('link_text', $companyId)->value;
|
||||
|
|
|
|||
BIN
kundesone.zip
BIN
kundesone.zip
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 4.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.9 KiB |
|
|
@ -712,10 +712,7 @@ class="form-control input-reply-textarea message_when_chat_is_closed">{!! $messa
|
|||
@csrf
|
||||
<div class="dev-input-group dev-input-group-input-info">
|
||||
<label>IP address *</label>
|
||||
@php
|
||||
$ip_addresses = getChatSetting('ip_addresses');
|
||||
@endphp
|
||||
<input type="text" name="ip_addresses" placeholder="Enter here" value="{{ $ip_addresses->value ?? '' }}">
|
||||
<input type="text" name="ip_addresses" placeholder="Enter here">
|
||||
<div class="dev-input-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>
|
||||
|
|
@ -731,6 +728,29 @@ class="form-control input-reply-textarea message_when_chat_is_closed">{!! $messa
|
|||
</form>
|
||||
</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 class="dev-tabcontent dev-tabcontent-canned">
|
||||
|
|
|
|||
|
|
@ -208,53 +208,53 @@ function updateStatusOptions(selectedFilter) {
|
|||
<!--chat avialability ajax-->
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#toggleSwitch').on('change', function() {
|
||||
const isChecked = $(this).is(':checked');
|
||||
// $('#toggleSwitch').on('change', function() {
|
||||
// const isChecked = $(this).is(':checked');
|
||||
|
||||
if (isChecked) {
|
||||
// Call route when toggle is ON
|
||||
$.ajax({
|
||||
url: 'update/chat-availability',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': "{{ csrf_token() }}"
|
||||
},
|
||||
data: {
|
||||
status: 'on'
|
||||
},
|
||||
success: function(response) {
|
||||
console.log('Success:', response);
|
||||
if(response.success) {
|
||||
toastr.success('Chat Availability Updated Successfully');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error:', error);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Call route when toggle is OFF
|
||||
$.ajax({
|
||||
url: 'update/chat-availability',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': "{{ csrf_token() }}"
|
||||
},
|
||||
data: {
|
||||
status: 'off'
|
||||
},
|
||||
success: function(response) {
|
||||
console.log('Success:', response);
|
||||
if(response.success) {
|
||||
toastr.success('Chat Availability Updated Successfully');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error:', error);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
// if (isChecked) {
|
||||
// // Call route when toggle is ON
|
||||
// $.ajax({
|
||||
// url: 'update/chat-availability',
|
||||
// method: 'POST',
|
||||
// headers: {
|
||||
// 'X-CSRF-TOKEN': "{{ csrf_token() }}"
|
||||
// },
|
||||
// data: {
|
||||
// status: 'on'
|
||||
// },
|
||||
// success: function(response) {
|
||||
// console.log('Success:', response);
|
||||
// if(response.success) {
|
||||
// toastr.success('Chat Availability Updated Successfully');
|
||||
// }
|
||||
// },
|
||||
// error: function(xhr, status, error) {
|
||||
// console.error('Error:', error);
|
||||
// }
|
||||
// });
|
||||
// } else {
|
||||
// // Call route when toggle is OFF
|
||||
// $.ajax({
|
||||
// url: 'update/chat-availability',
|
||||
// method: 'POST',
|
||||
// headers: {
|
||||
// 'X-CSRF-TOKEN': "{{ csrf_token() }}"
|
||||
// },
|
||||
// data: {
|
||||
// status: 'off'
|
||||
// },
|
||||
// success: function(response) {
|
||||
// console.log('Success:', response);
|
||||
// if(response.success) {
|
||||
// toastr.success('Chat Availability Updated Successfully');
|
||||
// }
|
||||
// },
|
||||
// error: function(xhr, status, error) {
|
||||
// console.error('Error:', error);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -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-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>
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@
|
|||
Route::post('store/tags', [ChatSettingController::class, 'storeTags'])->name('store.tags');
|
||||
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::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::post('logout', [LoginController::class, 'logout'])->name('logout');
|
||||
|
|
|
|||
Loading…
Reference in New Issue