<?php
namespace App\Http\Controllers;
use App\Crud;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Faker\Generator;
class CrudsController extends Controller
{
// * create
public function create(Generator $faker)
{
// generate fake data
$crud = new Crud();
$crud->name = $faker->lexify('????????');
$crud->color = $faker->boolean ? 'red' : 'green';
$crud->save();
// return saved data as JSON format
return response($crud->jsonSerialize(), Response::HTTP_CREATED);
}
// ...
}