title: How to Calculate Distance in laravel using lat long
body: <p>How can i calculate distance in laravel5.5 with SQL query ?
  My code mention below.</p>
  
  <pre><code>$specialProducts = Products::select('products.id', 'products.name', 'products.product_img', 'products.slug', 'products.price','products.lat','(3959 * ACOS(COS(RADIANS($lat))* COS(RADIANS(22.2765097))* COS(RADIANS(70.792523) - RADIANS(70.7583265))+ SIN(RADIANS(22.2897874))* SIN(RADIANS(22.2765097)))) AS distance')
              -&gt;join('subcategories', 'subcategories.id', '=', 'products.sub_category_id')
              -&gt;join('categories', 'categories.id', '=', 'subcategories.category_id')
              -&gt;join('store', 'store.id', '=', 'products.store_id')
              -&gt;where('products.status', 1)
              -&gt;where('products.special', 1)
  
              -&gt;orderBy('products.created_at', 'DESC')
              -&gt;get();
  </code></pre>