-
Notifications
You must be signed in to change notification settings - Fork 49
Open
Description
Guys,
I've been struggling with a generic implementation of Trucker in my app.
I want an implementation where I can configure the end-point in a ModelResource since we're using multiple external resources.
App/Resources/ProfileResource
<?php
namespace App\Resources;
use App\CoreConfig;
use Trucker\Facades\Config as TruckerConfig;
use Trucker\Resource\Model;
class ProfileResource extends Model
{
var $request = [
'base_uri' => 'https://profiler.local',
'driver' => 'rest',
'http_method_param' => null,
];
public function __construct()
{
TruckerConfig::set('auth.basic.username', CoreConfig::getConfig('api:Profiler:username'));
TruckerConfig::set('auth.basic.password', CoreConfig::getConfig('api:Profiler:password'));
}
}
App/Model/Profile
<?php
namespace App;
use \App\Resources\ProfileResource;
class Profile extends ProfileResource
{
//
}
To test:
# php artisan tinker
>>> $test = new \App\Profile;
=> App\Profile {#878
+request: [
"base_uri" => "https://profiler.local",
"driver" => "rest",
"http_method_param" => null,
],
+nestedUnder: null,
}
>>> $test->all();
Guzzle\Common\Exception\RuntimeException with message 'Unable to parse response body into JSON: 4'
>>> $test->errors();
=> []
>>>
How can I debug? see what is happening?
Metadata
Metadata
Assignees
Labels
No labels