-1
我遇到了一個不知道如何從url獲取值的問題。我是揹包裏的新人。請幫我這個.....Laravel 5.2揹包從url中獲取參數
我希望我的視圖基於從另一個視圖傳遞的ID,如何實現這個?這是我的代碼
Adcontroller.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>';
}
}
route.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();
}
}
「我想顯示基於每個廣告的評論,現在它顯示來自評論表的所有評論,我應該在哪裏寫條件???」 等待響應...............
我只是想根據每個廣告的評論 –
我不需要一個選擇列,我需要列出我的數據庫審查詳細信息的視圖是基於廣告ID ..該廣告ID必須傳遞另一種可以在我的評論控制器中訪問的視圖。爲此,我該怎麼辦? –
對不起,我怕我還是不明白。你能否重新說明你的問題和/或包括一個例子?原則上,只有在view_2 @includes view_1中傳遞從view_1到view_2的變量纔是可能的。將視圖中的變量傳遞給控制器是不可能的,並且不遵循MVC原則。 – tabacitu