mb_substr
. Но я еще добавлю в копилку функцию mb_strimwidth
- https://www.php.net/manual/ru/function.mb-strimwid... не выпадут страницы которые были со слешем?
$ext = extrime::find()->orderBy(['dtae' => SORT_DESC])->all();
$provider = new ActiveDataProvider([
'query' => $ext,
'pagination' => [
'pageSize' => 10,
],
]);
<?= \yii\widgets\ListView::widget([
'dataProvider' => $provider,
'id' => 'restaurants-news',
'itemOptions' => ['class' => 'col-12 restaurants-news__item'],
'itemView' => 'partials/_view',
]); ?>
<?php if ($index === 1): ?>
// тут верстка для первой записи
<?php else: ?>
// тут для остальных
<?php endif; ?>
<img src="<?=$renderImage["src"]?>" alt="">
Route::get('/admin/users/', ['as' => 'adminusers','uses' => 'Admin\UsersController@index']);
Route::post('/admin/users/', ['as' => 'adminuserscreate','uses' => 'Admin\UsersController@create']);
Route::get('/admin/users/{id}', ['as' => 'user.edit','uses' => 'Admin\UsersController@edit']);
Route::put('/admin/users/', ['as' => 'adminusersupdate','uses' => 'Admin\UsersController@update']);
Route::delete('/admin/users/', ['as' => 'adminusersdelete','uses' => 'Admin\UsersController@delete']);
public static function fromUpload($name, $deleteAfter = true)
{
$webroot = Yii::getAlias('@webroot');
$uploadImage = UploadedFile::getInstanceByName($name);
$instance = new Image();
$instance->ext = pathinfo($uploadImage->name, PATHINFO_EXTENSION);
$instance->title = basename($uploadImage->name);
$instance->size = $uploadImage->size;
if ($instance->size == 0)
return null;
if ($instance->save()) {
$url = strtr('/media/images/{date}/{id}/{file}', ['{date}' => date('Y/m/d'), '{id}' => $instance->id, '{file}' => $uploadImage->name]);
$destPath = $webroot . $url;
FileHelper::createDirectory(dirname($destPath), 0777);
if ($uploadImage->saveAs($destPath, $deleteAfter)) {
list($width, $height) = self::dimension($destPath);
$instance->setAttributes([
'url' => $url,
'width' => $width,
'height' => $height,
'mime' => $uploadImage->type,
'name' => $uploadImage->name,
'title' => '',
]);
$instance->update(false);
return $instance;
} else {
$instance->delete();
return null;
}
}
return null;
}