* @link https://docs.octobercms.com/3.x/extend/system/models.html
*/
class UserProject extends Model
{
use \October\Rain\Database\Traits\Validation;
use \Tailor\Traits\BlueprintRelationModel;
/**
* @var string table name
*/
public $table = 'palmo_userprojects_user_projects';
/**
* @var array rules for validation
*/
public $rules = [
'investment_size' => 'required|numeric|min:1',
'start_cost' => 'required|numeric|min:1',
// 'project_id' =>'unique:palmo_userproject_user_projects,user_id,1'
];
public $belongsTo = [
'user' => [User::class],
'project' => [
\Tailor\Models\EntryRecord::class,
'blueprint' => '770d7f99-6513-4f12-a962-701630c2a45d'
],
];
public $fillable = [
'project_id',
'user_id',
'investment_size'
];
public $attachMany = ['documents' => ['System\Models\File']];
}
Судя по ошибке напутаны модели. Ибо он ищет связь user_projects и UserProject модели.
вот так я расширял плагин, и на версии октобер 3.5.27 все работатет <?php namespace Palmo\UserProjects; use Backend; use System\Classes\PluginBase; use Lovata\Buddies\Models\User as UserModel; use Lovata\Buddies\Controllers\Users as UserController; /** * Plugin Information File * * @link https://docs.octobercms.com/3.x/extend/system/plugins.html */ class Plugin extends PluginBase { /** * pluginDetails about this plugin. */ public function pluginDetails() { return [ 'name' => 'UserProjects', 'description' => 'No description provided yet...', 'author' => 'Palmo', 'icon' => 'icon-leaf' ]; } /** * register method, called when the plugin is first registered. */ public function register() { // } /** * boot method, called right before the request route. */ public function boot() { UserModel::extend(function ($model){ $model->hasMany['user_projects'] = ['Palmo\UserProjects\Models\UserProject']; $model->addCachedField(['user_projects']); }); UserController::extendFormFields(function ($form, $model, $contex){ $form->addTabFields([ "user_projects" =>[ "label"=> "Проекты", "tab"=>"Проекты", 'type' => 'relation', 'controller' => [ 'label'=>'Проект', 'view'=>[ 'list' =>'$/palmo/userprojects/models/userproject/columns.yaml', 'recordsPerPage'=>10, ], 'manage'=>[ 'form' =>'$/palmo/userprojects/models/userproject/fields.yaml', ], ] ] ]); }); }
Так и в новой версии. Вопрос в том, почему он user_projects ищет у дочерней модели, а не у зверя. Попробуйте кеш скинуть глобально, раз поле кешируемое.
Обсуждают сегодня