本文整理汇总了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;
}