public function testRandomPhotoWithFilters() { VCR::insertCassette('photos.yml'); $filters = ['category' => [2, 3], 'featured' => true, 'username' => 'andy_brunner', 'query' => 'ice', 'w' => 100, 'h' => 100]; $photo = Unsplash\Photo::random($filters); VCR::eject(); $this->assertEquals('ZUaqqMxtxYk', $photo->id); $this->assertEquals('https://unsplash.imgix.net/photo-1428681756973-d318f055795a?q=75&fm=jpg&w=100&h=100&fit=max&s=b223d24e28ba1ced6731e98d46cd5f83', $photo->urls['custom']); }
protected function generate($year, $month) { HttpClient::init(['applicationId' => env('IMG_ID'), 'secret' => env('IMG_SECRET')]); $date = Carbon::now(); $date->year = $year; $date->month = $month; $date->startOfMonth(); $end = $date->copy()->endOfMonth(); while ($date->lte($end)) { $random = uPhoto::random(); $link = $random->links['html']; $image = $random->urls['thumb']; Photo::create(['date' => $date->toDateString(), 'link' => $link, 'image' => $image]); $date->addDays(1); } return redirect('view/' . $year . '/' . $month); }