7-Views - Page 2 of 8 - Developers Blog

How to get the current user in a __construct method of controller

Posted by
January 31, 2021

This issue arises because the controller __construct method executes before any middleware. so it returns null when we call auth()->user() So the solution of the issue is, inside your Controller __construct method call this. public function __construct() { $this->middleware(function ($request, $next) { dump(auth()->user()); return $next($request); }); }  

read more

Reverse Geocoding – Get formatted address from latitude and longitude

Posted by
July 3, 2020

<script> function getmylocation(lat, lng) { var currAddress, addtress= []; var geocoder = new google.maps.Geocoder(); var latlng = new google.maps.LatLng(lat, lng); if (geocoder) { geocoder.geocode({‘latLng’: latlng}, function (results, status) { if (status == google.maps.GeocoderStatus.OK) { if (results[0]) { currAddress = results[0].formatted_address; addtress.push(currAddress ); } else { alert(‘No results found’); } } else { alert(‘Geocoder failed due […]

read more

MySQL – UPDATE query with LIMIT

Posted by
July 24, 2019

Many a times there are certain conditions where ou want to update your records with certain limit attached to it. To update multiple rows using limit in MySQL can be implement by a query: UPDATE table_name SET field=’1′ WHERE id IN (SELECT id FROM (SELECT id FROM table_name LIMIT 0, 10) tmp);  

read more