| xqd
@@ -38,6 +38,27 @@ class LandMarkController extends BaseController
|
|
|
return $this->api($data);
|
|
|
}
|
|
|
|
|
|
+ public function getSearch(Request $request)
|
|
|
+ {
|
|
|
+ $userAuth = Auth('api')->user();
|
|
|
+ if(!$userAuth) return $this->error(null, ErrorCode::NO_AUTH);
|
|
|
+ $keyword = '%'.$request->input('keywords').'%';
|
|
|
+ if(empty($keyword)){
|
|
|
+ $data = MapLandmarkModel::all();
|
|
|
+ }else{
|
|
|
+ $data = MapLandmarkModel::where([['title','like',$keyword]])->orWhere([['subtitle','like',$keyword]])->get();
|
|
|
+ }
|
|
|
+ foreach ($data as $key=>$val){
|
|
|
+ $like = MapLikeModel::where([['user_id',$userAuth->id],['mark_id',$val->id]])->first();
|
|
|
+ if($like){
|
|
|
+ $val->isLike=1;
|
|
|
+ }else{
|
|
|
+ $val->isLike=0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $this->api($data);
|
|
|
+ }
|
|
|
+
|
|
|
public function getDetail(Request $request)
|
|
|
{
|
|
|
$validator = Validator::make($request->all(), [
|