Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
1 merge request!12api: fix 'projects' endpoint, don't paginate, always return JSON
......@@ -17,14 +17,7 @@ class FundingController extends Controller
*/
public function index(Request $request)
{
$projects = Project::paginate(15);
// If the request has header `Accept: */json`, return JSON
if ($request->wantsJson())
{
return ProjectResource::collection($projects);
}
return view('projects.index')
->with('projects', $projects);
return ProjectResource::collection(Project::all());
}
/**
......
......@@ -15,13 +15,15 @@ class ProjectResource extends JsonResource
public function toArray($request)
{
return [
'subaddr_index' => $this->subaddr_index,
'status' => $this->status,
'address' => $this->address,
'author' => $this->author,
'contributions' => $this->contributions,
'date' => $this->created_at->format('F j, Y'),
'percentage_funded' => $this->percentage_funded,
'raised_amount' => $this->raised_amount,
'state' => $this->state,
'target_amount' => $this->target_amount,
'percentage_funded' => $this->percentage_funded,
'qrcode' => ['base64' => base64_encode($this->qrcode)],
'contributions' => $this->contributions,
'title' => $this->title,
];
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment