Skip to content

Instantly share code, notes, and snippets.

@freshface
Created July 17, 2017 19:30
Show Gist options
  • Save freshface/92b717ba1f4e47958626b6a67a8c63df to your computer and use it in GitHub Desktop.
Save freshface/92b717ba1f4e47958626b6a67a8c63df to your computer and use it in GitHub Desktop.
// Routes
$api->get('projects', 'App\Api\V1\Controllers\ProjectController@index');
$api->post('projects', 'App\Api\V1\Controllers\ProjectController@store');
// Controller
<?php
namespace App\Api\V1\Controllers;
use App\Api\V1\Models\Project;
use App\Api\V1\Controllers\BaseController;
use Dingo\Api\Http\Request;
class ProjectController extends BaseController
{
public function index(Request $request)
{
echo 'index';
}
public function show($id)
{
$project = Project::findOrFail($id);
return $this->response->array($project->toArray());
}
public function store(Request $request)
{
echo 'stored';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment