Mélanie  Faria

Mélanie Faria

1657035628

Encontrar Localização Próxima Usando Latitude E Longitude Em Laravel 9

Se você tiver lugares, hotéis, casas, cidades, estados, países, produtos, revendedores, fornecedores, etc. com locais de latitude e longitude, poderá simplesmente encontrá-los facilmente nas proximidades. Vou te dar um exemplo simples. adicionaremos latitude e longitude na tabela de usuários e encontraremos usuários pela latitude e longitude mais próximas.

Vamos seguir o passo abaixo para fazer este exemplo.

Passo 1: Instale o Laravel

antes de tudo, precisamos obter um novo aplicativo de versão do Laravel usando o comando abaixo, então abra seu terminal OU prompt de comando e execute o comando abaixo:

composer create-project laravel/laravel blog

Etapa 2: criar rota

Nesta etapa, precisamos criar uma rota para chegar perto da localização do exemplo lat e long.

rotas/web.php

<?php  use Illuminate\Support\Facades\Route;  use App\Http\Controllers\LocationController;  /*|--------------------------------------------------------------------------| Web Routes|--------------------------------------------------------------------------|| Here is where you can register web routes for your application. These| routes are loaded by the RouteServiceProvider within a group which| contains the "web" middleware group. Now create something great!|*/  Route::get('near-by-places', [LocationController::class, 'index']);

Etapa 3: criar controlador

nesta etapa, precisamos criar LocationController e adicionar o seguinte código nesse arquivo. você tem uma tabela de usuários com colunas lat e long. também adicione alguns registros fictícios na tabela.

app/Http/Controllers/LocationController.php

<?php  namespace App\Http\Controllers;  use Illuminate\Http\Request;use App\Model\User;  class LocationController extends Controller{    /**     * Display a listing of the resource.     *     * @return \Illuminate\Http\Response     */    public function index(Request $request)    {        $lat = YOUR_CURRENT_LATTITUDE;        $lon = YOUR_CURRENT_LONGITUDE;                   $users = User::select("users.id"                        ,DB::raw("6371 * acos(cos(radians(" . $lat . "))                         * cos(radians(users.lat))                         * cos(radians(users.lon) - radians(" . $lon . "))                         + sin(radians(" .$lat. "))                         * sin(radians(users.lat))) AS distance"))                        ->groupBy("users.id")                        ->get();        dd($users);    }}

Execute o aplicativo Laravel:

Todas as etapas necessárias foram feitas, agora você deve digitar o comando abaixo e pressionar enter para executar o aplicativo Laravel:

php artisan serve

Agora, vá para o seu navegador da web, digite o URL fornecido e visualize a saída do aplicativo:

http://localhost:8000/near-by-places

espero que possa te ajudar... 

Fonte: https://www.itsolutionstuff.com/post/laravel-9-find-nearest-location-by-latitude-and-longitude-exampleexample.html

#laravel 

What is GEEK

Buddha Community

Encontrar Localização Próxima Usando Latitude E Longitude Em Laravel 9
Mélanie  Faria

Mélanie Faria

1657035628

Encontrar Localização Próxima Usando Latitude E Longitude Em Laravel 9

Se você tiver lugares, hotéis, casas, cidades, estados, países, produtos, revendedores, fornecedores, etc. com locais de latitude e longitude, poderá simplesmente encontrá-los facilmente nas proximidades. Vou te dar um exemplo simples. adicionaremos latitude e longitude na tabela de usuários e encontraremos usuários pela latitude e longitude mais próximas.

Vamos seguir o passo abaixo para fazer este exemplo.

Passo 1: Instale o Laravel

antes de tudo, precisamos obter um novo aplicativo de versão do Laravel usando o comando abaixo, então abra seu terminal OU prompt de comando e execute o comando abaixo:

composer create-project laravel/laravel blog

Etapa 2: criar rota

Nesta etapa, precisamos criar uma rota para chegar perto da localização do exemplo lat e long.

rotas/web.php

<?php  use Illuminate\Support\Facades\Route;  use App\Http\Controllers\LocationController;  /*|--------------------------------------------------------------------------| Web Routes|--------------------------------------------------------------------------|| Here is where you can register web routes for your application. These| routes are loaded by the RouteServiceProvider within a group which| contains the "web" middleware group. Now create something great!|*/  Route::get('near-by-places', [LocationController::class, 'index']);

Etapa 3: criar controlador

nesta etapa, precisamos criar LocationController e adicionar o seguinte código nesse arquivo. você tem uma tabela de usuários com colunas lat e long. também adicione alguns registros fictícios na tabela.

app/Http/Controllers/LocationController.php

<?php  namespace App\Http\Controllers;  use Illuminate\Http\Request;use App\Model\User;  class LocationController extends Controller{    /**     * Display a listing of the resource.     *     * @return \Illuminate\Http\Response     */    public function index(Request $request)    {        $lat = YOUR_CURRENT_LATTITUDE;        $lon = YOUR_CURRENT_LONGITUDE;                   $users = User::select("users.id"                        ,DB::raw("6371 * acos(cos(radians(" . $lat . "))                         * cos(radians(users.lat))                         * cos(radians(users.lon) - radians(" . $lon . "))                         + sin(radians(" .$lat. "))                         * sin(radians(users.lat))) AS distance"))                        ->groupBy("users.id")                        ->get();        dd($users);    }}

Execute o aplicativo Laravel:

Todas as etapas necessárias foram feitas, agora você deve digitar o comando abaixo e pressionar enter para executar o aplicativo Laravel:

php artisan serve

Agora, vá para o seu navegador da web, digite o URL fornecido e visualize a saída do aplicativo:

http://localhost:8000/near-by-places

espero que possa te ajudar... 

Fonte: https://www.itsolutionstuff.com/post/laravel-9-find-nearest-location-by-latitude-and-longitude-exampleexample.html

#laravel 

Seamus  Quitzon

Seamus Quitzon

1595201363

Php how to delete multiple rows through checkbox using ajax in laravel

First thing, we will need a table and i am creating products table for this example. So run the following query to create table.

CREATE TABLE `products` (
 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
 `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
 `description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
 `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
 `updated_at` datetime DEFAULT NULL,
 PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

Next, we will need to insert some dummy records in this table that will be deleted.

INSERT INTO `products` (`name`, `description`) VALUES

('Test product 1', 'Product description example1'),

('Test product 2', 'Product description example2'),

('Test product 3', 'Product description example3'),

('Test product 4', 'Product description example4'),

('Test product 5', 'Product description example5');

Now we are redy to create a model corresponding to this products table. Here we will create Product model. So let’s create a model file Product.php file under app directory and put the code below.

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    protected $fillable = [
        'name','description'
    ];
}

Step 2: Create Route

Now, in this second step we will create some routes to handle the request for this example. So opeen routes/web.php file and copy the routes as given below.

routes/web.php

Route::get('product', 'ProductController@index');
Route::delete('product/{id}', ['as'=>'product.destroy','uses'=>'ProductController@destroy']);
Route::delete('delete-multiple-product', ['as'=>'product.multiple-delete','uses'=>'ProductController@deleteMultiple']);

#laravel #delete multiple rows in laravel using ajax #laravel ajax delete #laravel ajax multiple checkbox delete #laravel delete multiple rows #laravel delete records using ajax #laravel multiple checkbox delete rows #laravel multiple delete

Juned Ghanchi

1621508419

Laravel App Development Company in India, Hire Laravel Developers

Hire our expert team of Laravel app developers for flexible PHP applications across various cloud service providers.

With this easy build technology, we develop feature-rich apps that make your complex business process a lot easier. Our apps are,

  • More secure and scalable.
  • A good framework lets you manage and organize resources better.
  • And have a rich community base.

Get your business a best in classlaravel app. Hire laravel app developers in India. We have the best organizational set-up to provide you the most advanced app development services.

#laravel app development company india #hire laravel developers india #laravel app development company #hire laravel developers #laravel development agency #laravel app programmers

How to Send E-mail Using Queue in Laravel 7/8

Today I will show you How to Send E-mail Using Queue in Laravel 7/8, many time we can see some process take more time to load like payment gateway, email send, etc. Whenever you are sending email for verification then it load time to send mail because it is services. If you don’t want to wait to user for send email or other process on loading server side process then you can use queue.

Read More : How to Send E-mail Using Queue in Laravel 7/8

https://websolutionstuff.com/post/how-to-send-e-mail-using-queue-in-laravel-7-8


Read Also : Send Mail Example In Laravel 8

https://websolutionstuff.com/post/send-mail-example-in-laravel-8

#how to send e-mail using queue in laravel 7/8 #email #laravel #send mail using queue in laravel 7 #laravel 7/8 send mail using queue #laravel 7/8 mail queue example

Liz  Fernandes

Liz Fernandes

1670234150

Best Laravel Development Company

In the present world, PHP is a well-liked framework. Laravel is one of the most well-known frameworks out there. The popularity of Laravel is due to its expressiveness, flexibility, good controllers, strength, seamless caching, and time savings when handling tasks like routing, authentication, sessions, and many more.

Laravel is a PHP framework that everyone who knows PHP should be familiar with. The Laravel PHP framework is simple to learn and use, but it is packed with useful features. Despite rising market competition, many developers consider Laravel to be one of the best PHP frameworks available.

WPWeb Infotech is a top Laravel development company in India and the US since 2015. They develop reliable, scalable Laravel web and mobile apps using Ajax-enabled widgets, MVC patterns, and built-in tools. WPWeb Infotech has top-notch expertise in combining a variety of front- and back-end technologies like Laravel + VueJS, Laravel + Angular, and Laravel + ReactJS to create scalable and secure web architectures, so you don't have to worry about scalability and flexibility while developing your product. They understand business scale and recommend technology that fits. Agile experts reduce web and mobile app development time and risk.

When it comes to hiring Laravel developers from India, they are the best choice because their Laravel developers can work according to your time zone to provide you with hassle-free, innovative, and straightforward web development solutions. Being the most trusted Laravel development company in India, they can help you reach new heights of success, unleashing the power of the Laravel PHP framework.

Partner with one of India’s best Laravel Development Company and get the most expertise in Laravel development.

#laravel  #laravel-development #laravel-development-company #laravel-development-services #hire-laravel-developers