...
 
Commits (2)
......@@ -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,
];
}
}