您好我有一种方法可以改变普通字母上的抛光字母。例如:
łódź更改为 lodz
或
Michał改为 Michal
private $letter = array( 'Ę', 'Ó', 'Ą', 'Ś', 'Ł', 'Ż', 'Ź', 'Ć', 'Ń', 'ę', 'ó', 'ą',
'ś', 'ł', 'ż', 'ź', 'ć', 'ń' );
private $change = array( 'E', 'O', 'A', 'S', 'L', 'Z', 'Z', 'C', 'N', 'e', 'o', 'a',
's', 'l', 'z', 'z', 'c', 'n' );
public function changeLetter( $string )
{
$string = str_replace( $this->letter, $this->change, $string );
$string = preg_replace( '#[^a-z0-9]#is', ' ', $string );
$string = trim( $string );
return $string;
}
将新记录保存到数据库的方法:
public function store(CreateWarehouseRequest $request){
$downloadNameWarehouse = Input::get('name_warehouse');
$changeLetter = $this->changeLetter($downloadNameWarehouse);
$warehouse = new warehouse($request->all());
Auth::user()->warehouses()->save($warehouse);
}
如何将验证changeLetter添加到方法store
?