laravel-5.1

Laravel Collection get unique values from nested datastructure

怎甘沉沦 提交于 2020-12-01 12:10:09
问题 I want to use Laravel 5.1 Collection's Unique method to filter unique IDs from nested objects. Given the data structure { "key1": [ {"id": 1}, {"id": 1} ], "key2": [ {"id": 1}, {"id": 2} ] } I want to return the same datastructure with duplicate id 1 removed from "key 1". I wanted to use $unique = $collection->unique('id'); , but this doesn't seem to apply to a nested datastructure as I have. So I thought to use $collection $input = $request->all(); $collection = collect($input); $collection-

Nearby stores in Laravel

时光总嘲笑我的痴心妄想 提交于 2020-11-28 10:45:49
问题 i'm try to get neraby store in Laravel 5.1 I have geocoding parser that caluclate coorinate. But i have problem with haversine formulas. Basically i need that from table Aziende (Stores) given a lat, long e category passed trough url, fetch the nearby stores. I try with this code: $dove = Input::get('dove'); $categoria_id = Input::get('id_categoria'); // 4: check if any matches found in the database table if (!empty($dove)) { $response = \GoogleMaps::load('geocoding')->setParamByKey ('address