You probably will be able to override those methods:
<?php
class Post extends Eloquent {
protected function getAttributeValue($key)
{
$value = parent::getAttributeValue($key);
return is_string($value) ? trim($value) : $value;
}
public function setAttribute($key, $value)
{
parent::setAttribute($key, $value);
if (is_string($value))
{
$this->attributes[$key] = trim($value);
}
}
}
And you should never get an untrimmed value again.
EDIT:
Tested this here and I got no spaces:
Route::any('test', ['as' => 'test', function()
{
$d = Post::find(2);
$d->title_en = " Markdown Example ";
dd($d);
}]);