Anatoliy
Well-known member
So I built an add-on (slightly modified Notes add-on from Building with XF 2 videos).
Now I want to add an option to add a water body, that was fished (by selecting from a drop-down). And It's on a border of my knowledge and I barely understand how to do that.
Do I need to add two more tables?
One for the list of water bodies, and another table where add-on will add Note id and Water body id?
Please untangle me. )
PHP:
<?php
namespace AV\Notes\Entity;
use XF\Mvc\Entity\Entity;
use XF\MVC\Entity\Structure;
class Note extends Entity
{
public static function getStructure(Structure $structure): Structure
{
$structure->table = 'av_notes_note';
$structure->shortName = 'AV\Notes:Note';
$structure->contentType = 'av_notes_note';
$structure->primaryKey = 'note_id';
$structure->columns = [
'note_id' => ['type' => self::UINT, 'autoIncrement' => true],
'user_id' => ['type' => self::UINT, 'default' => \XF::visitor()->user_id],
'post_date' => ['type' => self::UINT, 'default' => \XF::$time],
'from' => ['type' => self::STR, 'default' => '00:00'],
'till' => ['type' => self::STR, 'default' => '23:59'],
'quality' => ['type' => self::STR],
'content' => ['type' => self::STR],
'steelhead' => ['type' => self::UINT, 'default' => 0],
'salmon' => ['type' => self::UINT, 'default' => 0],
'trout' => ['type' => self::UINT, 'default' => 0],
'bass' => ['type' => self::UINT, 'default' => 0],
'tuna' => ['type' => self::UINT, 'default' => 0],
'lingcod' => ['type' => self::UINT, 'default' => 0],
'panfish' => ['type' => self::UINT, 'default' => 0],
];
$structure->relations = [
'User' => [
'entity' => 'XF:User',
'type' => self::TO_ONE,
'conditions' => 'user_id',
'primary' => true,
],
];
$structure->defaultWith = ['User'];
$structure->getters = [];
$structure->behaviors = [];
return $structure;
}
}
Now I want to add an option to add a water body, that was fished (by selecting from a drop-down). And It's on a border of my knowledge and I barely understand how to do that.
Do I need to add two more tables?
One for the list of water bodies, and another table where add-on will add Note id and Water body id?
Please untangle me. )