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


PHP Story::where方法代码示例

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


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

示例1: getBeastData

 public function getBeastData($id)
 {
     $retArray = array();
     if (Beast::where('TaxonID', '=', $id)->count() > 0) {
         $beast = Beast::where('TaxonID', '=', $id)->first();
         if (isset($beast->AcceptedCommonName)) {
             $beastName = '%' . $beast->AcceptedCommonName . '%';
             $stories = Story::where(function ($query) use($beastName) {
                 $query->where('Subjects', 'like', $beastName)->orWhere('Keywords', 'like', $beastName);
             })->get();
             $retArray['stories'] = $stories;
         }
         $sightings = Sighting::where('TaxonID', '=', $id)->orderBy('Date', 'DESC');
         if ($sightings->count() > 0) {
             $sighting = $sightings->first();
             if (isset($beast->ScientificName)) {
                 $apiSighting = $this->getLatestAPISighting($beast->ScientificName);
                 if (count($apiSighting > 0) && $apiSighting[0] > $sighting->Date) {
                     $retArray['sighting'] = array('longitude' => $apiSighting[1][0], 'latitude' => $apiSighting[1][1], 'date' => $apiSighting[0], 'name' => $apiSighting[2]);
                 } else {
                     $retArray['sighting'] = array('longitude' => $sighting->Longitude, 'latitude' => $sighting->Latitude, 'date' => $sighting->Date, 'name' => $sighting->Username);
                 }
             } else {
                 $retArray['sighting'] = array('longitude' => $sighting->Longitude, 'latitude' => $sighting->Latitude, 'date' => $sighting->Date, 'name' => $sighting->Username);
             }
         } else {
             if (isset($beast->ScientificName)) {
                 $apiSighting = $this->getLatestAPISighting($beast->ScientificName);
                 if (count($apiSighting) > 0) {
                     $retArray['sighting'] = array('longitude' => $apiSighting[1][0], 'latitude' => $apiSighting[1][1], 'date' => $apiSighting[0], 'name' => $apiSighting[2]);
                 } else {
                     $retArray['sighting'] = array();
                 }
             } else {
                 $retArray['sighting'] = array();
             }
         }
         $retArray['info'] = $beast;
     }
     return $retArray;
 }
开发者ID:johnnyluu,项目名称:anemu,代码行数:41,代码来源:AnimalController.php


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