Thursday, 11 May 2017

Laravel Query Log - Check Query & Array Pass

Enable Query Log

Laravel can optionally log in memory all queries that have been run for the current request. Be aware that in some cases, such as when inserting a large number of rows, this can cause the application to use excess memory. To enable the log, you may use the enableQueryLog( ) method:

\DB::enableQueryLog();
        Alumni::with('alumni_careers')->findOrFail($id);
        $result = \DB::getQueryLog();
        dump($result);


With the code above , we can check wether the alumni table has relationship with alumni_careers table as define in model class. The output will be like below :









No comments:

Post a Comment