public function getClientDashboard($client_id = null) { if (!$client_id) { return null; } $client = \RTMatt\MonthlyService\Client::find($client_id); return view("rtclientdashboard::components.dashboard-component", ['dashboard_data' => $client->getServiceReport(), 'dashboard_id' => $client->id, 'admin_mode' => true]); }
/** @test */ public function it_returns_client_services_object_and_200_when_all_is_well() { $plan = factory(ServicePlan::class, 1)->create(); $client = Client::find($plan->client_id); $key = $client->generateApiKey(); $header = $key->api_name . ":" . \Hash::make($key->api_secret_key); $header_encoded = base64_encode($header); $response = $this->get(route('client-services-summary'), ['HTTP_Authorization' => $header_encoded])->seeJsonStructure(['last_backup', 'monthly', 'annual', 'description']); $this->assertResponseOk(); }
public function test($client_id = null) { if (!$client_id) { $rt_client = \RTMatt\MonthlyService\Client::first(); } else { $rt_client = \RTMatt\MonthlyService\Client::find($client_id); } if (!$rt_client) { return "No client found"; } $key = $rt_client->api_key; $username = $key->api_name; $password = \Hash::make($key->api_secret_key); $client = new Client(['base_uri' => config('rtclientdashboard.api_base_url')]); $response = $client->request('GET', route('client-services-summary'), ['auth' => [$username, $password]]); $dashboard_data = json_decode($response->getBody()->getContents()); $auth = base64_encode("{$username}:{$password}"); return view('rtclientdashboard::dashboard', compact('dashboard_data', 'rt_client', 'client_id', 'auth')); }