- Add support for handling relations in CURD operations - Optimize model associations to use hasOne instead of belongsTo - Implement field selection for relations - Update controller to handle AJAX requests and return JSON data Modify model to include relation methods
28 lines
645 B
Plaintext
28 lines
645 B
Plaintext
<?php
|
|
|
|
namespace {{controllerNamespace}};
|
|
|
|
use app\common\controller\AdminController;
|
|
use app\admin\service\annotation\ControllerAnnotation;
|
|
use app\admin\service\annotation\NodeAnnotation;
|
|
use think\App;
|
|
|
|
#[ControllerAnnotation(title: '{{controllerAnnotation}}')]
|
|
class {{controllerName}} extends AdminController
|
|
{
|
|
|
|
private array $notes;
|
|
|
|
public function __construct(App $app)
|
|
{
|
|
parent::__construct($app);
|
|
self::$model = {{modelFilename}}::class;
|
|
$notes = self::$model::$notes;
|
|
{{constructRelation}}
|
|
$this->notes =$notes;
|
|
$this->assign(compact('notes'));
|
|
}
|
|
|
|
{{indexMethod}}
|
|
|
|
} |