Помогите настроить, у меня slug лежит в отдельной таблице
таблицы
Код: Выделить всё
post
id | title
post_slug
post_id | slug
Код: Выделить всё
use yii\behaviors\SluggableBehavior;
class PostSlug extends \yii\db\ActiveRecord
{
public $title;
public static function tableName()
{
return 'post_slug';
}
public function rules()
{
return [
[['slug'], 'string', 'max' => 200],
[['slug'], 'unique'],
[['title'], 'save'],
[['post_id'], 'exist', 'skipOnError' => true, 'targetClass' => Post::class, 'targetAttribute' => ['post_id' => 'id']],
];
}
public function behaviors()
{
return [
[
'class' => SluggableBehavior::className(),
'attribute' => 'title',
'slugAttribute' => 'slug',
],
];
}
сохранение в котроллере
Код: Выделить всё
$model_slug->title = $model->title;
$model_slug->save();
PHP Fatal Error – yii\base\ErrorException
Maximum execution time of 30 seconds exceeded
в логах ничего конкретного.
Причем пробовал делать
Код: Выделить всё
$model_slug->slug = Inflector::slug($model->title);