Posts

How to write MySql Query in laravel?

I will show a simple query in laravel where you can easily understand that how query works in laravel 4. $limit = 5; $value= Bank::where('isactive','=','yes')->where('money','>',0)->whereNotNull('account')->whereNull('credit')->take($limit)->orderBy('id', 'DESC')->get(); This query act like as query below select * from Bank where money>0 amd account!=null and credit='' order by id desc limit 0,5. This is the representation that how laravel query works i added here where condition with 3 different ways and limti and order by for this query This query will work for both Database MYSQL MongoDB

How to get XML response output in laravel?

How to get XML response output in laravel? or How to create XML response output in laravel? or Most of developers use header function to create xml file but this does not work header('Content-type: application/xml'); $output  = "<?xml version='1.0' encoding='UTF-8'?>"; here i will tell you that how can you show or save XML response output in laravel you have an array where you have data Here is an example that how can you create xml file response in laravel suppose you have an array which have twitter data //Preapre our output for xml data $output  = "<?xml version='1.0' encoding='UTF-8'?>"; $output .= "\n<twitterfeed>\n"; $j=0; foreach($twitterinfo as $row){ $j++; $output .= "<feed>\n"; $output .= "<id>" . $j . "</id>\n"; $output .= "<twitter_id>" . $row['twitter_id'] . "</twitter_id>\n"

How to rename a field from a collection in mongoDB?

How to rename a field from a collection in mongoDB? By this query you can rename a field from whole collection in mongoDB db.colleciton.update(     //  where query like: where active="yes"     {         "active" : "yes"     },       // will remove Name field from current collection     {         $rename: {"Name":"Username"}     },       // options     {         "multi" : true  // update all document     } ); or you can copy and paste this code above code is with comment that how mongoDB query works db.colleciton.update(     {         "active" : "yes"     },     {         $rename: {"Name":"Username"}     },     {         "multi" : true     } );

How to remove a field from a collection in mongoDB?

How to remove a field from a collection in mongoDB? By this query you can remove a field from whole collection in mongoDB db.colleciton.update(     //  where query like: where active="yes"     {         "active" : "yes"     },         // will remove Name field from current collection     {         $unset: {"Name":""}     },         // options     {         "multi" : true  // update all document     } ); or you can copy and paste this code above code is with comment that how mongoDB query works db.colleciton.update(     {         "active" : "yes"     },     {         $unset: {"Name":""}     },     {         "multi" : true     } );

EntityRef: expecting ';' error while creating the xml file?

This page contains the following errors: error on line 68 at column 18: EntityRef: expecting ';' Below is a rendering of the page up to the first error. Generally  this error occured when any value have & in the value between tag example:  <Name>PHP & C</Name> So & break the xml and due to this it shows the error just replace   & with  &amp   in your value field example:  $output .= "<Name>" . str_replace('&', '&amp;', $row['name']) . "</Name>"; I hope this will help you. If helped then dont forget to comment to inspire me :)

No hint path defined for [folder] in laravel?

No hint path defined for [folder] in laravel. There could be several reasone for this error in laravel. But most of time it works like a charm to solve this probelm - No hint path defined for If you will check your view file which you have include in your controller or routes. then  you will find that on view file you have some code like this in your view/file.php @extends('Folder::layouts.default') Or @include('Folder::includes.header') to pass the view in templates so where folder is mention you can change the folder  path where your file is located.

How to remove blank array from an array?

How to remove blank array  from an array? like: you have an array where a key is blank and you want to remove the array from the tree of array then you can use this function like: function unsetblankarray($array)     {         foreach($array as $key=>$value)         {             if(!@$array[$key]['field'])             {                 unset($array[$key]);             }         }         return $array; }