08 2024
This commit is contained in:
parent
04d677d37a
commit
bfa3bb1df4
1191 changed files with 637397 additions and 10619 deletions
102
app/Services/SyS/CleanHTMLProductDescription.php
Normal file
102
app/Services/SyS/CleanHTMLProductDescription.php
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
namespace App\Services\SyS;
|
||||
|
||||
use App\Models\Product;
|
||||
use Request;
|
||||
use App\Models\TransProduct;
|
||||
use App\Models\UserCreditItem;
|
||||
|
||||
class CleanHTMLProductDescription
|
||||
{
|
||||
|
||||
public static function show()
|
||||
{
|
||||
dump("CleanHTMLProductDescription");
|
||||
// dd('check function');
|
||||
$TransProducts = TransProduct::limit(2000)->get();
|
||||
dump(count($TransProducts));
|
||||
$c = 0;
|
||||
foreach($TransProducts as $item){
|
||||
if($item->value){
|
||||
$item->value = self::cleanHTML($item->value);
|
||||
$item->save();
|
||||
|
||||
//dump($item->value);
|
||||
$c++;
|
||||
}
|
||||
}
|
||||
dump("counter TransProduct");
|
||||
dump($c);
|
||||
|
||||
$Products = Product::limit(2000)->get();
|
||||
dump(count($Products));
|
||||
$c = 0;
|
||||
foreach($Products as $item){
|
||||
if($item){
|
||||
$item->copy = self::cleanHTML($item->copy);
|
||||
$item->description = self::cleanHTML($item->description);
|
||||
$item->usage = self::cleanHTML($item->usage);
|
||||
$item->ingredients = self::cleanHTML($item->ingredients);
|
||||
|
||||
$item->save();
|
||||
|
||||
//dump($item->value);
|
||||
$c++;
|
||||
}
|
||||
}
|
||||
|
||||
dump("counter");
|
||||
dd($c);
|
||||
}
|
||||
|
||||
public static function cleanHTML($html)
|
||||
{
|
||||
// $html = preg_replace("/(</?)div/", "$1p", $html);
|
||||
|
||||
$html = str_replace('<p> </p>', '', $html);
|
||||
$html = str_replace('<p></p>', '', $html);
|
||||
$html = str_replace('<p><br></p>', '', $html);
|
||||
$html = str_replace('<p><br></p>', '', $html);
|
||||
|
||||
$html = str_replace('<br>', '', $html);
|
||||
$html = str_replace('text -primary', 'text-primary', $html);
|
||||
$html = str_replace('fa -check', 'fa-check', $html);
|
||||
$html = str_replace('text- primary', 'text-primary', $html);
|
||||
$html = str_replace('fa- check', 'fa-check', $html);
|
||||
$html = str_replace('<ul class="list-unstyled list-icons" style="padding-left: 15px;"> </ul>', '', $html);
|
||||
|
||||
$html = str_replace('</span>', '', $html);
|
||||
$html = preg_replace('/(<[^>]+) style=".*?"/i', '$1', $html);
|
||||
|
||||
$html = str_replace('<li></li>', '', $html);
|
||||
$html = str_replace('<li> </li>', '', $html);
|
||||
$html = str_replace('< i', '<i', $html);
|
||||
$html = str_replace('< li>', '<li>', $html);
|
||||
|
||||
$html = str_replace('</ i>', '</i>', $html);
|
||||
$html = str_replace('</ li>', '</li>', $html);
|
||||
|
||||
$html = str_replace('</ b>', '</b>', $html);
|
||||
$html = str_replace('< /b>', '</b>', $html);
|
||||
|
||||
$html = str_replace('</ p>', '</p>', $html);
|
||||
$html = str_replace('< /p>', '</p>', $html);
|
||||
|
||||
$html = str_replace('< /i>', '</i>', $html);
|
||||
$html = str_replace('< /li>', '</li>', $html);
|
||||
$html = str_replace('<div>', '', $html);
|
||||
$html = str_replace('</div>', '', $html);
|
||||
$html = str_replace('>>', '>', $html);
|
||||
return $html;
|
||||
|
||||
}
|
||||
|
||||
public static function store()
|
||||
{
|
||||
$data = Request::all();
|
||||
\Session()->flash('alert-save', true);
|
||||
return back();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue