cavinz

MySql : To get first not null value in select query

If we want to get first not null value we have function in mysql to get this result COALESCE Example : TABLE STRUCTURE ——————————————– | id | customername | mobile | home | work | ——————————————– | 1 | Joe | 123 | 456 | 789 | ——————————————– | 2...Read more …
cavinz

Javascript : Get Credit card type from number

If we want to get credit card type from input number we have two methods https://jquerycreditcardvalidator.com/ ( from this url you can get the source and implement easily ) below is the function to fetch type <script type=”text/javascript”> function cardtype(number) { var re = new RegExp(“^4”); if (number.match(re) != null)...Read more …
cavinz

Laravel : Pass variable in orWhere condition

Please check below example: $id = “something”; DB::table(‘users’) ->where(‘name’, ‘=’, ‘John’) ->where(function ($query)  as ($id)  { // use this $id in query if you want $query->where(‘votes’, ‘>’, 100) ->orWhere(‘title’, ‘=’, ‘Admin’); }) ->get();Read more …