In Laravel 5.8 app submitting form with the data I need to clear data, like doubled spaces, so I created middleware with clearing code : app/Http/Middleware/WorkTextString.php :
<?php
namespace App\Http\Middleware;
use Closure;
use App\Http\Traits\funcsTrait;
use function PHPSTORM_META\type;
class WorkTextString
{
use funcsTrait;
public function handle($request, Closure $next, $strip_tags_excluding= false )
{
$inputDataArray = $request->all();
\Log::info($request->all());
$stripTagsExcludingArray= $this->pregSplit('/ /',$strip_tags_excluding);
foreach( $inputDataArray as $next_field_name=>$next_field_value ) {
if ( !empty($next_field_value) and is_string($next_field_value) ) {
$skip_strip_tags= in_array($next_field_name,$stripTagsExcludingArray);
$inputDataArray[$next_field_name] = $this->workTextString($next_field_value, $skip_strip_tags);
}
}
\Log::info('$inputDataArray:: ::'); // I CHECK AND SEE CLEARED DATA!
\Log::info($inputDataArray);
$request->replace($inputDataArray); // THAT DOWS NOT WORK ?
return $next($request);
}
}
But I see that submitted data are not cleared. Lokks like $request->replace does not work for me...
in routes/api.php :
Route::resource('skills', 'API\Admin\SkillController')->middleware('WorkTextString');
How correctly ?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2s4P6kP
via IFTTT
Aucun commentaire:
Enregistrer un commentaire