PHP code example of laraveldaily / apigenerator
1. Go to this page and download the library: Download laraveldaily/apigenerator library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
laraveldaily / apigenerator example snippets
namespace App\Http\Controllers\Api;
use App\Project;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class ProjectsController extends Controller
{
public function index()
{
return Project::all();
}
public function store(Request $request)
{
$project = Project::create($request->all());
return $project;
}
public function show($id)
{
return Project::findOrFail($id);
}
public function update(Request $request, $id)
{
$project = Project::findOrFail($id);
$project->update($request->all());
return $project;
}
public function destroy($id)
{
$project = Project::findOrFail($id);
$project->delete();
return '';
}
}