2014-09-23 32 views
0

我試圖進行CSS編輯,如果數據庫中沒有組顯示,因爲當「添加組」按鈕下面沒有組時,該按鈕沒有底部邊框。對不起,如果我對此完全錯誤,我是Laravel和PHP的新手。爲什麼這個Laravel控制器不能如何工作?

enter image description here

enter image description here

if(DB::table('forum_groups')->where('author_id')->first() >= 0) { 
      echo(' 
      <style type="text/css"> 
      a.btn.btn-default { 
       border-bottom-left-radius: 0; 
       border-bottom-right-radius: 0; 
       border-bottom: none; 
      } 
      </style> 
      '); 
} else {} 
+1

您嘗試比較一個對象與0,不這樣做。觀看laracasts.com上的一些內容以幫助您開始,因爲這一切看起來都很糟糕。 – 2014-09-23 07:04:55

回答

0

,而不是通過這樣的方式......你可以創建一個特殊的CSS類,它很多你的標籤,你可以從控制器來查看設置的值做

return View::make(your.page)->with('value',$value) 

鑑於你可以檢查例如

您的自定義CSS像

 .bottom_border { 
      border-bottom-left-radius: 0; 
      border-bottom-right-radius: 0; 
      border-bottom: none; 
     } 

和按鈕,例如,你可以像

<button class="btn btn-default {{ !empty($value) ? 'bottom_border' : '' }}">add Group </button> 

其中$值是您獲取的羣體,如果組存在上面的代碼將這個類添加到您的標記,如果不是,它不會。

我希望這會幫助你。

+0

我假設你正在使用刀片模板.. – justrohu 2014-09-23 05:12:55