Belongstomany same table

Hi I have a Ticket which contains several workers with different roles.
In my Tickets add method, I want to show some Form->control select boxes with these types. That’s why I put in the TicketsTable class the following lines:

$this->hasOne('Workers', [
    'classname' => 'Workers',
    'foreignKey' => 'worker_id',
    'propertyName' => 'workers'
    
]);
$this->hasOne('Clients', [
    'classname' => 'Workers',
    'foreignKey' => 'client_id',
    'propertyName' => 'clients'
]);

but in my TicketsController in the add method, I do not have some collect statement for tickets, because I want to create a new one.
When I try to select the clients or workers it will ends up in an error:

$clients = $this->Tickets->Clients->find('list', limit: 200)->all();
$worker = $this->Tickets->Workers->find('list', limit:200)->all();

Table class for alias Estatemanagers could not be found.

Can someone please help me? Thanks

None of the code you’ve shown says anything at all about Estatemanagers, so your error is in some other code.

Hi, sorry, it was my mistake. Postet the wrong error message:

Table class for alias Clients could not be found.

It seems to me, that relation between these tables (or one table) is not wokring proper.
And since I am adding a new ticket, I have no fetching of tickets, because I want to add a new one. But for this, I need the information from the other table.
Here is my add method in controller:

$ticket = $this->Tickets->newEmptyEntity();
$this->Authorization->authorize($ticket);
$user = $this->Authentication->getIdentity();

if ($this->request->is('post')) {
	$ticket = $this->Tickets->patchEntity($ticket, $this->request->getData());
	if ($this->Tickets->save($ticket)) {
		$this->Flash->success(__('The ticket has been saved.'));

		return $this->redirect(['action' => 'index']);
	}
	$this->Flash->error(__('The ticket could not be saved. Please, try again.'));
}

$clients = $this->Tickets->Clients->find('list', limit: 200)->all();
$workers = $this->Tickets->Workers->find('list', limit:200)->all();

$this->set(compact('ticket', 'workers', 'clients'));

And in my view add.php:

<div class="tickets form content">
	<?= $this->Form->create($ticket) ?>
	<fieldset>
		<legend><?= __('new Ticket')?></legend>

		<?php
			echo $this->Form->control('workers->id');
			echo $this->Form->control('client_id');
			echo $this->Form->control('summary');
			echo $this->Form->control('description');
		?>
	</fieldset>
	<?= $this->Form->button(__('send')) ?>
	<?= $this->Form->end() ?>
</div>

You have a file called src/Model/Table/WorkersTable.php which includes namespace App\Model\Table; and class WorkersTable ?

Yes for sure.
But do I have to specify the relationship in this WorkersTable too?
I mean the problem occurs in the TicketsController.

For me it is not 100% sure what to do because in docu I see no tables examples, just only the statements in Tables class.

To use $this->Tickets->Clients from the TicketsController, you need what you have in the TicketsModel. No requirement to have the reverse association set up in the WorkersTable, though of course you can if it makes sense.

Try changing from hasOne to belongsTo? I think that would better reflect the expected relationship (the workers exist regardless of the tickets; the tickets don’t exist without the workers).

If that doesn’t resolve it, maybe a bit of debugging of things like debug($this->Tickets->Clients) and debug(\Cake\Orm\TableRegistry::getTableLocator()->get('Workers')) would shed some light.