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


PHP Element::where方法代码示例

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


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

示例1: getPrev

 public function getPrev($chid)
 {
     $_action = 'show';
     $chapter = Chapter::find($chid);
     $book = Book::find($chapter->book_id);
     $firstTextElement = Element::where('chapter_id', '=', $chid)->where('type', '!=', '2')->first();
     $firstImage = Element::where('chapter_id', '=', $chid)->where('type', '=', '2')->first();
     $tmpELement = ['id' => $firstTextElement['id'], 'chapter_id' => $firstTextElement['chapter_id'], 'order' => $firstTextElement['order'], 'type' => $firstTextElement['type'], 'content' => $firstTextElement['content'], 'note' => $firstTextElement['note']];
     if ($firstTextElement['type'] == 4 || $firstTextElement['type'] == 5) {
         $tmpELement['content'] = json_decode($firstTextElement['content'], true);
         //dd($element['content']);
     }
     $prevInfo = ['chapter' => $chapter, 'book' => $book, 'info' => $tmpELement ?: null, 'img' => $firstImage ?: null];
     echo json_encode($prevInfo, JSON_NUMERIC_CHECK);
 }
开发者ID:spark942,项目名称:supinternet-projects,代码行数:15,代码来源:ChapterController.php

示例2: processElement

 private function processElement($skin, $file)
 {
     $processedElements = array();
     $oldanimationRegex = "/sliderb\\d|pippidonclear\\d|pippidonfail\\d|pippidonidle\\d|pippidonkiai\\d/";
     $rules = array('file' => 'skinmimes');
     $manualMove = false;
     if ($file->getSize() < 10 && in_array($file->getClientOriginalExtension(), array("mp3", "wav", "ogg"))) {
         $file = new UploadedFile(public_path() . "/blank.wav", $file->getClientOriginalName());
         $manualMove = true;
     }
     if (!in_array($file->getMimeType(), array("application/x-font-ttf", "text/plain"))) {
         $validation = Validator::make(array("file" => $file), $rules);
         if ($validation->fails()) {
             return "error";
         }
     }
     //processing of skin metadata
     $elementName = strtolower($file->getClientOriginalName());
     $elementExt = strtolower($file->getClientOriginalExtension());
     $filename = array("fullname" => $elementName, "filename" => rtrim(basename($elementName, $elementExt), "."), "fullnameUntouched" => $elementName, "extension" => $elementExt, "ishd" => strpos($elementName, "@2x"), "shouldScaleDown" => true, "hashdcounterpart" => false);
     $sizeDifference = 0;
     if ($filename['ishd']) {
         $filename['filename'] = substr($filename['filename'], 0, -3);
         $filename['fullname'] = $filename['filename'] . "." . $filename['extension'];
     }
     //pretty complex check if animatable element fits few ... things!
     $filename['issequence'] = (preg_match("/-\\d/", $filename['filename']) === 1 || preg_match("/\\d/", $filename['filename']) === 1 && preg_match($oldanimationRegex, $filename['filename']) === 1) && preg_match("/score-\\d|default-\\d|comboburst-\\d/", $filename['filename']) !== 1;
     // don't mark score digits as animatable elements - they are obviously not.
     if ($filename["issequence"] && !in_array($filename['extension'], array("mp3", "ogg", "wav"))) {
         preg_match("/\\d+\$/", $filename['filename'], $sequenceMatches);
         $filename['frame'] = $sequenceMatches[0];
         $filename['filename'] = substr($filename['filename'], 0, -strlen((string) $filename['frame']));
     } else {
         $filename['frame'] = -1;
     }
     $DBskinElements = SkinElement::where("filename", "=", $filename['filename'])->where("skin_id", "=", $skin->id)->get();
     if (isset($DBskinElements)) {
         foreach ($DBskinElements as $DBskinElement) {
             if ($DBskinElement->ishd == 0 && $DBskinElement->useroverriden == 1) {
                 $filename['shouldScaleDown'] = false;
             }
             if ($DBskinElement->ishd == 1) {
                 $filename['hashdcountepart'] = true;
             }
         }
     }
     $elementGroup = Element::where('element_name', '=', $filename['filename'])->first();
     if (in_array($filename['extension'], array("jpg", "jpeg", "png"))) {
         if ($filename["ishd"] && $filename['shouldScaleDown']) {
             $hdSkinElement = SkinElement::firstOrNew(array("skin_id" => $skin->id, "filename" => $filename['filename'], "extension" => $filename['extension'], "ishd" => 1, "sequence_frame" => $filename['frame']));
             $hdSkinElement->group_id = isset($elementGroup) ? $elementGroup->group_id : -1;
             if ($hdSkinElement->exists) {
                 $sizeDifference += $hdSkinElement->size;
             }
             $hdSkinElement->size = $file->getSize();
             $file->move(public_path() . "/skins-content/" . $skin->id, $hdSkinElement->getFullname());
             if ($filename['issequence']) {
                 $hdSkinElement->issequence = 1;
                 $hdSkinElement->sequence_frame = $filename['frame'];
             }
             $hdSkinElement->save();
             $processedElements[] = $hdSkinElement;
             $sdSkinElement = SkinElement::firstOrNew(array("skin_id" => $skin->id, "filename" => $filename['filename'], "extension" => $filename['extension'], "ishd" => 0, "sequence_frame" => $filename['frame']));
             $sdSkinElement->group_id = isset($elementGroup) ? $elementGroup->group_id : -1;
             $imageToResize = Image::make(public_path() . "/skins-content/" . $skin->id . "/" . $hdSkinElement->getFullname());
             $imageToResize->resize(ceil(floatval($imageToResize->width() / 2)), ceil(floatval($imageToResize->height() / 2)));
             $imageToResize->save(public_path() . "/skins-content/" . $skin->id . "/" . $filename['fullname']);
             if ($sdSkinElement->exists) {
                 $sizeDifference += $sdSkinElement->size;
             }
             $sdSkinElement->size = filesize(public_path() . "/skins-content/" . $skin->id . "/" . $filename['fullname']);
             if ($filename['issequence']) {
                 $sdSkinElement->issequence = 1;
                 $sdSkinElement->sequence_frame = $filename['frame'];
             }
             $sdSkinElement->save();
             $processedElements[] = $sdSkinElement;
         } else {
             $skinElement = SkinElement::firstOrNew(array("skin_id" => $skin->id, "filename" => $filename['filename'], "extension" => $filename['extension'], "ishd" => $filename['ishd'] ? 1 : 0, "sequence_frame" => $filename['frame']));
             $skinElement->group_id = isset($elementGroup) ? $elementGroup->group_id : -1;
             if ($skinElement->exists) {
                 $sizeDifference += $skinElement->size;
             }
             $skinElement->size = $file->getSize();
             if ($filename['issequence']) {
                 $skinElement->issequence = 1;
                 $skinElement->sequence_frame = $filename['frame'];
             }
             if (($skinElement->exists || !$filename['hashdcounterpart']) && $skinElement->ishd != 1) {
                 $skinElement->useroverriden = 1;
             }
             $skinElement->save();
             $processedElements[] = $skinElement;
             $file->move(public_path() . "/skins-content/" . $skin->id, $filename['fullnameUntouched']);
         }
     } else {
         $skinElement = SkinElement::firstOrNew(array("skin_id" => $skin->id, "filename" => $filename['filename'], "extension" => $filename['extension'], "ishd" => $filename['ishd'] ? 1 : 0));
         $skinElement->element_id = isset($elementGroup) ? $elementGroup->group_id : -1;
         if ($skinElement->exists) {
             $sizeDifference += $skinElement->size;
//.........这里部分代码省略.........
开发者ID:swatgbr,项目名称:osu-skins-db,代码行数:101,代码来源:SkinsController.php

示例3: getNew

 public function getNew()
 {
     $books = DB::table('books')->orderBy('created', 'desc')->take(8)->get();
     $formattedBooks = [];
     foreach ($books as $key => $book) {
         $tmpBook = ['id' => $book->id, 'name' => $book->name, 'traveler_id' => $book->traveler_id, 'likes' => $book->likes, 'created' => $book->created];
         // search first image of the book
         $tmpImg = null;
         $chapters = Chapter::where('book_id', '=', $book->id)->get();
         foreach ($chapters as $chapter) {
             $element = Element::where('chapter_id', '=', $chapter->id)->where('type', '=', '2')->first();
             if ($element) {
                 $tmpImg = $element;
                 break;
             }
         }
         if ($tmpImg) {
             $tmpBook['img'] = $tmpImg;
         }
         $formattedBooks[] = $tmpBook;
     }
     echo json_encode($formattedBooks, JSON_NUMERIC_CHECK);
 }
开发者ID:spark942,项目名称:supinternet-projects,代码行数:23,代码来源:BookController.php


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