Commit 8cdb68ee authored by Diego Salazar's avatar Diego Salazar
Browse files

Merge branch 'api-projects' into 'master'

api: fix 'projects' endpoint, don't paginate, always return JSON

Closes monero-site#689

See merge request !12
parents 07cb8b07 fa1683dd
...@@ -17,14 +17,7 @@ class FundingController extends Controller ...@@ -17,14 +17,7 @@ class FundingController extends Controller
*/ */
public function index(Request $request) public function index(Request $request)
{ {
$projects = Project::paginate(15); return ProjectResource::collection(Project::all());
// If the request has header `Accept: */json`, return JSON
if ($request->wantsJson())
{
return ProjectResource::collection($projects);
}
return view('projects.index')
->with('projects', $projects);
} }
/** /**
......
...@@ -15,13 +15,15 @@ class ProjectResource extends JsonResource ...@@ -15,13 +15,15 @@ class ProjectResource extends JsonResource
public function toArray($request) public function toArray($request)
{ {
return [ return [
'subaddr_index' => $this->subaddr_index, 'address' => $this->address,
'status' => $this->status, 'author' => $this->author,
'contributions' => $this->contributions,
'date' => $this->created_at->format('F j, Y'),
'percentage_funded' => $this->percentage_funded,
'raised_amount' => $this->raised_amount, 'raised_amount' => $this->raised_amount,
'state' => $this->state,
'target_amount' => $this->target_amount, 'target_amount' => $this->target_amount,
'percentage_funded' => $this->percentage_funded, 'title' => $this->title,
'qrcode' => ['base64' => base64_encode($this->qrcode)],
'contributions' => $this->contributions,
]; ];
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment