React ternary operator



var isLoggedIn = false;
var domain = 'pt';
var passwordLogin = false;
var b = false;
var c = false;



let message = (isLoggedIn === true && domain != 'pt') ? <Component {...props} /> :
  (isLoggedIn === true && config.domain == 'pt' && passwordLogin === true) ? <Component {...props} /> :
  (isLoggedIn === true && config.domain == 'pt' && passwordLogin == false) ? <Redirect to={{ pathname: '/newlogin' }} /> :
  (isLoggedIn === false && config.domain==='pt') ? window.location.replace('http://n.com/pt/360-vr?device=smart&offer=1') :
  <Redirect to={{ pathname: '/login' }} />

alert( message );


            

Laravel Join With AND/OR Condition.


Example Query.

Select * from abc_tbl 
inner join xyz_tbl on anb_tbl.id = xyz_tbl.userId AND anb_tbl.otherid = xyz_tbl.otherid

User Below Snippets.

$query_que = \DB::table('abc_tbl');

$query_que->join('xyz_tbl', function($join) {
            $join->on('abc_tbl.id', '=', 'xyz_tbl.userId');
            $join->on('anb_tbl.otherid', '=', 'xyz_tbl.otherid');
});


Laravel 5.5 – How to log all Eloquent Queries


In this post, I will show you simple method to log each and every Eloquent Query of your application executes. We gonna log queries to the storage/logs/laravel.log file.

To log database queries we gonna add a database calls lister as shown in the below example. Open your app/Providers/AppServiceProvider.php and add following code to boot() method:


namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
use DB;
use Log;

class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        Schema::defaultStringLength(191);

        DB::listen(function($query) {
            Log::info(
                $query->sql,
                $query->bindings,
                $query->time
            );
        });
    }

Example log data

[2017-12-04 18:57:33] local.INFO: select * from `tasks`  
[2017-12-04 18:57:33] local.INFO: select count(*) as aggregate from `tasks`  
[2017-12-04 18:57:33] local.INFO: select * from `tasks` limit 15 offset 0  
[2017-12-04 18:57:33] local.INFO: select * from `tasks`  
[2017-12-04 18:57:33] local.INFO: select count(*) as aggregate from `tasks`  
[2017-12-04 18:57:33] local.INFO: select * from `tasks` limit 15 offset 0  
I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.