本文整理汇总了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;
}
示例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));
}
}
示例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"> ';
} elseif ($element_name == "brewer" && $element->logo()) {
$html .= '<img src="' . $element->logo()->path . '" style="height:15px"> ';
}
$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]);
}
示例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'));
}
示例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');
}
示例6: deleteStyle
/**
* Deletes the speified style
* @param $id
* @return mixed
*/
public function deleteStyle($id)
{
Style::find($id)->delete();
return Redirect::back();
}