Replace deprecated array and string helpers

Laravel recommends using the `Str` and `Arr` class methods directly instead of the respective helper functions. These helper functions are deprecated in Laravel 5.8 and removed in Laravel 6.
This commit is contained in:
Shift
2023-01-06 11:53:35 +00:00
parent 03623d493d
commit b02541ac64
28 changed files with 91 additions and 70 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Agent\helpdesk;
// models
use Illuminate\Support\Str;
use App\Http\Controllers\Admin\MailFetch as Fetch;
use App\Http\Controllers\Controller;
use App\Model\helpdesk\Email\Emails;
@@ -253,7 +254,7 @@ class MailController extends Controller
$disposition = $structure->disposition;
}
$filename = str_random(16).'-'.$attachment->getFileName();
$filename = Str::random(16).'-'.$attachment->getFileName();
$type = $attachment->getMimeType();
$size = $attachment->getSize();
$data = $attachment->getData();

View File

@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Agent\helpdesk;
// controllers
use Illuminate\Support\Str;
use App\Http\Controllers\Common\FileuploadController;
use App\Http\Controllers\Common\NotificationController as Notify;
use App\Http\Controllers\Common\PhpMailController;
@@ -665,7 +666,7 @@ class TicketController extends Controller
}
$user->role = 'user';
$user->active = $user_status;
$token = str_random(60);
$token = Str::random(60);
$user->remember_token = $token;
// mail user his/her password
//\Event::fire(new \App\Events\ClientTicketFormPost($from_data, $emailadd, $source));
@@ -2688,7 +2689,7 @@ class TicketController extends Controller
if (isset($tickets->ticket_title)) {
$string = utfEncoding($tickets->ticket_title);
if (strlen($string) > 25) {
$string = str_limit($string, 30).'...';
$string = Str::limit($string, 30).'...';
}
} else {
$string = Lang::get('lang.no-subject');
@@ -2757,7 +2758,7 @@ class TicketController extends Controller
$color = "<i class='fa fa-exclamation-triangle' title='".Lang::get('lang.accoutn-not-verified')."'></i>";
}
return "<a href='".$url."' title='".Lang::get('lang.see-profile1').' '.strip_tags($name).'&apos;'.Lang::get('lang.see-profile2')."'><span style='color:#508983'>".str_limit(strip_tags($name), 30).' <span style="color:#f75959">'.$color.'</span></span></a>';
return "<a href='".$url."' title='".Lang::get('lang.see-profile1').' '.strip_tags($name).'&apos;'.Lang::get('lang.see-profile2')."'><span style='color:#508983'>".Str::limit(strip_tags($name), 30).' <span style="color:#f75959">'.$color.'</span></span></a>';
})
->editColumn('a_uname', function ($tickets) {
if ($tickets->assigned_to == null && $tickets->name == null) {
@@ -3126,7 +3127,7 @@ class TicketController extends Controller
})
->addColumn('title', function ($tickets) {
if (isset($tickets->ticket_title)) {
$string = str_limit($tickets->ticket_title, 20);
$string = Str::limit($tickets->ticket_title, 20);
} else {
$string = '(no subject)';
}
@@ -3182,7 +3183,7 @@ class TicketController extends Controller
$color = "<i class='fa fa-exclamation-triangle' title='".Lang::get('lang.accoutn-not-verified')."'></i>";
}
return "<a href='".$url."' title='".Lang::get('lang.see-profile1').' '.ucfirst($tickets->user_name).'&apos;'.Lang::get('lang.see-profile2')."'><span style='color:#508983'>".ucfirst(str_limit($name, 30)).' <span style="color:#f75959">'.$color.'</span></span></a>';
return "<a href='".$url."' title='".Lang::get('lang.see-profile1').' '.ucfirst($tickets->user_name).'&apos;'.Lang::get('lang.see-profile2')."'><span style='color:#508983'>".ucfirst(Str::limit($name, 30)).' <span style="color:#f75959">'.$color.'</span></span></a>';
})
->addColumn('assign_user_name', function ($tickets) {
if ($tickets->assigned_to == null) {

View File

@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Agent\kb;
// Controllers
use Illuminate\Support\Str;
use App\Http\Controllers\Controller;
// Requests
use App\Http\Requests\kb\ArticleRequest;
@@ -72,7 +73,7 @@ class ArticleController extends Controller
/* add column name */
->addColumn('name', function ($model) {
$name = str_limit($model->name, 20, '...');
$name = Str::limit($model->name, 20, '...');
return "<p title=$model->name>$name</p>";
})
@@ -155,7 +156,7 @@ class ArticleController extends Controller
$publishTime = $request->input('year').'-'.$request->input('month').'-'.$request->input('day').' '.$request->input('hour').':'.$request->input('minute').':00';
$sl = $request->input('name');
$slug = str_slug($sl, '-');
$slug = Str::slug($sl, '-');
$article->slug = $slug;
$article->publish_time = $publishTime;
$article->fill($request->except('created_at', 'slug'))->save();
@@ -225,7 +226,7 @@ class ArticleController extends Controller
$id = $aid->id;
$sl = $request->input('slug');
$slug = str_slug($sl, '-');
$slug = Str::slug($sl, '-');
// dd($slug);
$article->slug = $slug;

View File

@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Agent\kb;
// Controllers
use Illuminate\Support\Str;
use App\Http\Controllers\Agent\helpdesk\TicketController;
use App\Http\Controllers\Controller;
// Requests
@@ -77,7 +78,7 @@ class CategoryController extends Controller
->addColumn('name', function ($model) {
$string = strip_tags($model->name);
return str_limit($string, 20);
return Str::limit($string, 20);
})
/* add column Created */
->addColumn('Created', function ($model) {
@@ -140,7 +141,7 @@ class CategoryController extends Controller
{
/* Get the whole request from the form and insert into table via model */
$sl = $request->input('name');
$slug = str_slug($sl, '-');
$slug = Str::slug($sl, '-');
$category->slug = $slug;
// send success message to index page
try {
@@ -182,7 +183,7 @@ class CategoryController extends Controller
/* Edit the selected category via id */
$category = Category::where('id', $id)->first();
$sl = $request->input('name');
$slug = str_slug($sl, '-');
$slug = Str::slug($sl, '-');
/* update the values at the table via model according with the request */
//redirct to index page with success message
try {

View File

@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Agent\kb;
use Illuminate\Support\Str;
use App\Http\Controllers\Agent\helpdesk\TicketController;
use App\Http\Controllers\Controller;
// request
@@ -126,7 +127,7 @@ class PageController extends Controller
public function store(PageRequest $request)
{
$sl = $request->input('name');
$slug = str_slug($sl, '-');
$slug = Str::slug($sl, '-');
$this->page->slug = $slug;
try {
@@ -167,7 +168,7 @@ class PageController extends Controller
// get pages with respect to slug
$pages = $this->page->where('slug', $slug)->first();
$sl = $request->input('name');
$slug = str_slug($sl, '-');
$slug = Str::slug($sl, '-');
try {
$pages->fill($request->all())->save();