当前位置: 首页>>代码示例>>PHP>>正文


PHP Style::find方法代码示例

本文整理汇总了PHP中Style::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Style::find方法的具体用法?PHP Style::find怎么用?PHP Style::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Style的用法示例。


在下文中一共展示了Style::find方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validate_style_id

 public function validate_style_id()
 {
     $errors = array();
     if (!is_integer($this->style_id) || !Style::find($this->style_id)) {
         $errors[] = "style does not exist";
     }
     return $errors;
 }
开发者ID:Rochet2,项目名称:Tsoha-Bootstrap,代码行数:8,代码来源:beer.php

示例2: show_vars

 public static function show_vars(&$vars, $id)
 {
     $vars['brewery'] = Brewery::find($vars['val']->brewery_id);
     $vars['style'] = Style::find($vars['val']->style_id);
     $ratings = Rating::find_by('beer_id', $id);
     if (count($ratings) > 0) {
         $sum = 0.0;
         foreach ($ratings as $r) {
             $sum += $r->rating;
         }
         $vars['average'] = $sum / count($ratings);
     }
     $vars['ratings'] = array();
     foreach ($ratings as $k => $v) {
         $vars['ratings'][] = array('rating' => $v, 'user' => User::find($v->user_id));
     }
 }
开发者ID:Rochet2,项目名称:Tsoha-Bootstrap,代码行数:17,代码来源:beer_controller.php

示例3: searchElement

 public function searchElement($element_name, $text = null)
 {
     $html = "";
     $elements = [];
     $db_elements = DB::table($element_name)->where('name', 'like', "%" . $text . "%")->get();
     foreach ($db_elements as $db_element) {
         switch ($element_name) {
             case "beer":
                 $elements[] = Beer::find($db_element->id);
                 break;
             case "brewer":
                 $elements[] = Brewer::find($db_element->id);
                 break;
             case "locality":
                 $elements[] = Locality::find($db_element->id);
                 break;
             case "style":
                 $elements[] = Style::find($db_element->id);
                 break;
         }
     }
     foreach ($elements as $element) {
         $html .= '<li class="list-group-item clearfix">';
         if ($element_name == "locality" && $element->flag()) {
             $html .= '<img src="' . $element->flag()->path . '" style="height:15px">&nbsp;';
         } elseif ($element_name == "brewer" && $element->logo()) {
             $html .= '<img src="' . $element->logo()->path . '" style="height:15px">&nbsp;';
         }
         $html .= '<span>' . $element->name . '</span>' . '<div class="btn-group pull-right">';
         if ($element_name == "brewer" || $element_name == "beer") {
             $html .= '<a href="' . URL::to('/dashboard/' . $element_name . 's/edit/' . $element->id) . '">';
         }
         $html .= '<button type="button" class="btn btn-info" ';
         if ($element_name != "brewer" && $element_name == "beer") {
             $html .= 'onclick="editElement(' . $element->id . ')"';
         }
         $html .= '>Edit</button>';
         if ($element_name == "brewer" || $element_name == "beer") {
             $html .= '</a>';
         }
         $html .= '<a href="' . URL::to('/dashboard/' . $element_name . 's/delete/' . $element->id) . '"><button type="button" class="btn btn-danger">Delete</button></a>';
         $html .= '</div></li>';
     }
     return Response::json(['html' => $html]);
 }
开发者ID:andreuramos,项目名称:beers,代码行数:45,代码来源:AjaxController.php

示例4: edit

 /**
  * Show the form for editing the specified style.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $style = Style::find($id);
     return View::make('styles.edit', compact('style'));
 }
开发者ID:hopshoppub,项目名称:hopshop.dev,代码行数:11,代码来源:StylesController.php

示例5: store

 /**
  * Store a newly created resource in storage.
  * POST /beer
  *
  * @return Response
  */
 public function store()
 {
     if (Input::get('beer_id')) {
         $beer = Beer::find(Input::get('beer_id'));
         echo "already in db beer";
     } else {
         $beer = new Beer();
         echo "new beer!";
     }
     $brewers = [];
     for ($i = 1; $i <= Input::get('brewer-count'); $i++) {
         $brewer = Brewer::find(Input::get('brewer-' . $i . '_id'));
         if (!$brewer) {
             return Redirect::back()->withInput()->withMessage('Invalid Brewer ' . $i);
         }
         $brewers[] = $brewer->id;
     }
     $style = Style::find(Input::get('style_id'));
     if (!$style) {
         return Redirect::back()->withInput()->withMessage('Invalid Style');
     }
     $beer->name = Input::get('name');
     //$beer->brewer_id = $brewer->id;
     $beer->style_id = $style->id;
     $beer->ratebeer = Input::get('ratebeer_url');
     $beer->beeradvocate = Input::get('beeradvocate_url');
     $beer->album = Input::get('album');
     $beer->page = Input::get('page');
     $beer->position = Input::get('position');
     $beer->save();
     $beer->brewer()->sync($brewers);
     for ($i = 1; $i <= Input::get('sticker-count'); $i++) {
         if (Input::hasFile('sticker-' . $i)) {
             $f = Input::file('sticker-' . $i);
             //Change the image name: s<number_of_service>-<filename>.
             $filename = 'beerr-' . $beer->id . '-' . $f->getClientOriginalName();
             //Move it to our public folder
             $f->move(public_path() . '/upload/', $filename);
             //This is the path to show it on the web
             $complete_path = '/upload/' . $filename;
             //create the gallery
             $image = array('path' => $complete_path, 'brewer_id' => NULL, 'beer_id' => $beer->id);
             $img = Image::create($image);
             if (Input::get('sticker-' . $i . '_id') != null) {
                 $sticker = Sticker::find(Input::get('sticker-' . $i . '_id'));
                 $sticker->img_id = $img->id;
                 $sticker->type = "front";
                 //Input::get('sticker-'.$i.'_type');
                 $sticker->save();
             } else {
                 $sticker = Sticker::create(['beer_id' => $beer->id, 'image_id' => $img->id, 'type' => "front"]);
             }
             echo "Sticker created " . $sticker->id;
         } else {
             if (Input::file('sticker-' . $i)->isValid()) {
                 echo "IS FUCKIN VALID";
             } else {
                 echo "IS FUCKIN INVALID";
             }
             echo 'sticker-' . $i . " has no file";
             echo "<pre>" . print_r(Input::all(), 1) . "</pre>";
             exit;
         }
     }
     return Redirect::to('dashboard/beers');
 }
开发者ID:andreuramos,项目名称:beers,代码行数:72,代码来源:BeerController.php

示例6: deleteStyle

 /**
  * Deletes the speified style
  * @param $id
  * @return mixed
  */
 public function deleteStyle($id)
 {
     Style::find($id)->delete();
     return Redirect::back();
 }
开发者ID:andreuramos,项目名称:beers,代码行数:10,代码来源:DashboardController.php


注:本文中的Style::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。