Monday, March 13, 2017

Query database and set the configuration in Laravel

On top of my config file /app/config/laravel-facebook-sdk.php, I am trying to query my database and set the value to my configuration accordingly base on specific user.


I have that user exist in my database

[
    {
        "id": 1006,
        "account_id": "1006",
        "email": "test@outlook.com",
        "created_at": "2017-03-10 14:33:36",
        "updated_at": "2017-03-10 16:38:58",
        "auto_provisioning": "0",
        "service_plan": null,
        "location_id": "29",
        "fb_email": "test@benunets.com3",
        "fb_app_id": "rrr1234rrrr", <-------------- this one 
        "fb_app_secret": "sdfasdfascrrrr" <-------------- this one 
    }
]


I'm trying to get access to these 2 fields :

  • "fb_app_id": "rrr1234rrrr",
  • "fb_app_secret": "sdfasdfascrrrr"

I tried

use App\User;

$account_id = '1006';
var_dump(User::where('account_id','=',$account_id)->first());


return [

    'facebook_config' => [
        'app_id' => env('FACEBOOK_APP_ID')? env('FACEBOOK_APP_ID') : '',
        'app_secret' => env('FACEBOOK_APP_SECRET')? env('FACEBOOK_APP_SECRET') : '',
    ],

    .... and more

];


I kept getting HTTP ERROR 500 error. I couldn't get my var_dump() to dipslay.


Any suggestions on how do I prevent that ?

How would one go abot and implement or continue debug something like this ?



via ihue

Advertisement