0

我遇到了一个不知道如何从 url 获取值的问题。我是背包的新手。请在这件事上给予我帮助.....

我想要基于从另一个视图传递的 id 的视图上的详细信息,如何实现?这是我的代码

广告控制器.php

 public $crud = array(
            "model" => "App\Larapen\Models\Ad",
            "entity_name" => "ad",
            "entity_name_plural" => "ads",
            "route" => "admin/ad",
            "reorder" => false,
            "add_permission" => false,
    "columns" => [
                [
                    'name' => 'reviewed',
                    'label' => "Reviewed",
                    'type' => "model_function",
                    'function_name' => 'getReviewedHtml',
                ],
             ],
    "fields" =>[
                    [   // Hidden
                            'name' => 'id',
                            'label' => "id",
                            'type' => 'hidden'
                        ],
            ],

        );

Ad.php(模型)

 public function getReviewedHtml()
    {
        if ($this->reviewed == 1) {
             return '<i class="fa fa-check-square-o" aria-hidden="true"></i><a href="reviews/'.$this->id.'"><span> Reviews</span></a>';
        } else {
            return '<i class="fa fa-square-o" aria-hidden="true"></i>';
        }
    }

路由.php

CRUD::resource('ad', 'AdController');
   CRUD::resource('reviews', 'AdReviewController');

AdReviewController.php

public $crud = array(
        "model" => "App\Larapen\Models\AdReviews",
        "entity_name" => "Reviews",
        "entity_name_plural" => "Reviews",
        "route" => "admin/reviews",
        "reorder" => false,
        "add_permission" => false,

        // *****
        // COLUMNS
        // *****
        "columns" => [
            [
                'name' => 'created_at',
                'label' => "Date",
            ],
            [
                'name' => 'user',
                'label' => "User",
                'type' => "model_function",
                'function_name' => 'getuser',
            ],
            [
                'name' => 'review',
                'label' => "Review",
            ],

        ],
  "fields" => [

             [
                'name' => 'review',
                'label' => "Review",
            ],


        ],
    );
public function __construct()
    {
        //$this->crud['update_fields'][1]['options'] = $this->adType();
       // $this->crud['update_fields'][2]['options'] = $this->categories();

        parent::__construct();
    }
     public function store(StoreRequest $request)
    {
        return parent::storeCrud();
    }

    public function update(UpdateRequest $request)
    {
        return parent::updateCrud();
    }

}

“我想显示基于每个广告的评论,现在它显示评论表中的所有评论,我应该在哪里写条件???” 等待回复......

4

1 回答 1

0

我假设您在 AdReview 和 Review 之间存在一对一一对多的关系,这在您的 Review 模型和 AdReview 模型中都定义了。

如果是这样,您可以添加:

这将显示它“连接”的实体并允许用户对其进行编辑。

这是你想要达到的目标吗?

于 2016-10-03T09:48:42.347 回答