Tag : toArray()


How to convert object to array in Laravel 5?

If you require to convert object data from db into array then you can do it using DB facade and Model Eloquent. Sometimes we need to give array data only so we must get array data from db. I have two examples so it can helps you. In first example, If you use Model Eloquent for get data from database then you can do it using toArray(). toArray() will help to convert object into array data. So let's see bellow example and check it. <strong>Example 1:</strong> <pre class="prettyprint lang-php"> $users = User::get()->toArray(); print_r($users); </pre> In this example, if you use DB facade for ge.....

By Hardik Savani | June 2, 2016 | | 7583 Viewer | Category : Laravel
READ MORE

    Laravel 5 - Simple user access control using Middleware

    Laravel 5 - Simple user access control using Middleware

    Open Post

    Laravel 5.4 New Feature - Add new Components & Slots in Blade Template

    Laravel 5.4 New Feature - Add new Components & Slots in Blade Template

    Open Post

    Laravel 5 - Google reCaptcha code and Validation example using anhskohbo/no-captcha package

    Laravel 5 - Google reCaptcha code and Validation example using anhskohbo/no-captcha package

    Open Post

    Jquery - input tags plugin example using jquery.tagsinput.js plugin

    Jquery - input tags plugin example using jquery.tagsinput.js plugin

    Open Post

    Laravel 5 create and download zip file example using chumper/zipper composer package

    Laravel 5 create and download zip file example using chumper/zipper composer package

    Open Post

    PHP - How to implement Google new reCAPTCHA Code Example with Demo?

    PHP - How to implement Google new reCAPTCHA Code Example with Demo?

    Open Post