I have a problem. I'm building a CMS in Cakephp based on the guide on their official website. Everything is going well but I have a problem. As the article adds, no service is generated. Everything is 100% done as per the tutorial.
Can you guess what it is caused by?
I put this in ArticlesTable, but it doesn't seem to work.
<?php
declare(strict_types=1);
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
use Cake\Utility\Text;
use Cake\Event\EventInterface;
class ArticlesTable extends Table
{
public function beforeSave($event, $entity, $options)
{
if ($entity->isNew() && !$entity->slug) {
$sluggedTitle = Text::slug($entity->title);
$entity->slug = substr($sluggedTitle, 0, 191);
}
}
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config): void
{
parent::initialize($config);
$this->setTable('articles');
$this->setDisplayField('title');
$this->setPrimaryKey('id');
$this->addBehavior('Timestamp');
$this->belongsTo('Users', [
'foreignKey' => 'user_id',
'joinType' => 'INNER',
]);
$this->belongsTo('Editions', [
'foreignKey' => 'edition_id',
'joinType' => 'INNER',
]);
$this->belongsTo('Categories', [
'foreignKey' => 'category_id',
'joinType' => 'INNER',
]);
$this->hasMany('ArticlesComments', [
'foreignKey' => 'article_id',
]);
$this->hasMany('ArticlesGalleries', [
'foreignKey' => 'article_id',
]);
}
Any ideas ?