mercredi 1 janvier 2020

How to display saved contenteditable contents properly? (laravel)

I have done saved the contents inside the #descrition below.

<div id="description" contenteditable="true"></div>

My problem is when I try to display it does not display like an html format, it displays same like the saved data with <h1></h1> & <br>. It displays plain text only.

<div id="description" contenteditable="true"></div>

The content I saved in my database & display:
<h1>Descriptoin</h1> Doner, where I built and maintained banner adverts and microsites. <br> And...

Someone know how to display this properly?



via Chebli Mohamed

Laravel Form submit - Debugging output using debugbar

I am working on Laravel 5.7 and I can see the debugging output as attached when performing ajax call. But unable to see the output when using form submit. Is there any way to see the output in Debugbar when performing Form submit ?

Following is my output



via Chebli Mohamed

Need MCQ Questions of Laravel Framework

I need 300+ mcq questions for testing skill, I have searched online but no luck. Can anyone provide me any link where I can find mcq questions about laravel.



via Chebli Mohamed

Laravel 5.8 - Using Multiple Models in Service or Controller Dynamically

I have a structure wherein the Models folder holds all the model files for the project feature-wise, Example - all the user-related model files will be inside the Models/User folder.

I want to use App\Models\User* Kind of thing which should make things simpler and also while constructing the object of the class all the models should be available to $this->



via Chebli Mohamed

how can I drop user from "system.users" using mongodb and PHP?

I need a small help.

I can not delete "System.User" user from MongoDB database.

/*Remove Tenent DB*/
function RemoveTenentDB($mydb){
   error_reporting(0);
   $connection_string = Config::get('database.creator-tenant-uri');
   $m = new MongoClient($connection_string); //create interface to mongo
   $command = array
   (
       "dropUser" => $mydb
   );
   $db = $m->selectDB( $mydb );
   $db->command( $command );
   #drop databse
   $db = $m->dropDB( $mydb );
   return true;
}

Below code delete just database and particular database user only not "System.User"

$command = array
   (
       "dropUser" => $mydb
   );
   $db = $m->selectDB( $mydb );
   $db->command( $command );
   $db = $m->dropDB( $mydb );

enter image description here



via Chebli Mohamed

Laravel - Custom Auth Middleware not redirecting properly for unauthorized user

I have created a custom auth controller for recognising unauthorized user and redirect them to login path. If logged in the middlewre is working absolutely fine, but showing error if not logged in. Here is my code

Middleware:

    class CheckUserAuthenticated
{
    public function handle($request, Closure $next)
    {
        if(auth()->check()) {
            $user_id =  auth()->user()->id;
            define('authenticated_user_id' ,$user_id);
            return $next($request);
        }
        return redirect('login'); // this code is not working
    }
}

Error:

enter image description here



via Chebli Mohamed

Is there any way to find location with in radius in laravel

How can I find radious based Location based on one point latitude and longitude and given radius. Suppose, I have given 30 as Radius than it will find result of that particular given latitude and longitude with in the 30 radius. I have tried below code:

    $lat = '37.421998'; // latitude of centre of bounding circle in degrees
    $lon = '-122.084000'; // longitude of centre of bounding circle in degrees
    $rad = 30; // radius of bounding circle in kilometers

    $R = 6371;  // earth's mean radius, km

    // first-cut bounding box (in degrees)
    $maxLat = $lat + rad2deg($rad/$R);
    $minLat = $lat - rad2deg($rad/$R);
    $maxLon = $lon + rad2deg(asin($rad/$R) / cos(deg2rad($lat)));
    $minLon = $lon - rad2deg(asin($rad/$R) / cos(deg2rad($lat)));

   $results = DB::select('Select id, latitude, longitude, acos(sin(:lat)*sin(radians(latitude)) + cos(:lat)*cos(radians(latitude))*cos(radians(longitude)-(:lon))) * (:R) As D From ( Select id, latitude, longitude From jobs_master Where latitude Between (:minLat) And (:maxLat) And longitude Between (:minLon) And (:maxLon) ) As FirstCut Where acos(sin(:lat)*sin(radians(latitude)) + cos(:lat)*cos( radians(latitude))*cos(radians(longitude)-(:lon))) * :R < :rad ', ['maxLat' => $maxLat,'maxLon' => $maxLon, 'minLat' => $minLat,'minLon' => $minLon, 'lat' => $lat,'lon' => $lon,'R'=> $R,'rad'=>$rad]);

        dd(DB::getQueryLog());exit;
        print_r($results);exit;

Can any one help me.



via Chebli Mohamed