Example #1
0
 public function trashesInsideTile()
 {
     $trashes = DB::select('
         SELECT *
         FROM trashes
     
         WHERE trashes.geom && ST_MakeEnvelope(?, ?, ?, ?)', [$this->sw_lat, $this->sw_lng, $this->ne_lat, $this->ne_lng]);
     //get id's of the trashes
     $trash_ids = [];
     foreach ($trashes as $trash) {
         $trash_ids[] = $trash->id;
     }
     $trashes = Trash::whereIn('id', $trash_ids)->get();
     return $trashes;
 }
Example #2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //find id
     $trash = Trash::findOrFail($id);
     //delete
     $trash->types()->delete();
     $trash->delete();
     //delete types
     return response()->json("{}", 200);
 }