PHP code example of salmanzafar / laravel-crud-generator
1. Go to this page and download the library: Download salmanzafar/laravel-crud-generator 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/ */
salmanzafar / laravel-crud-generator example snippets
angular2
namespace App\Http\Controllers;
use App\Http\Requests\CarRequest;
use App\Car;
class CarController extends Controller
{
public function index()
{
$cars = Car::latest()->get();
return response()->json($cars, 201);
}
public function store(CarRequest $request)
{
$car = Car::create($request->all());
return response()->json($car, 201);
}
public function show($id)
{
$car = Car::findOrFail($id);
return response()->json($car);
}
public function update(CarRequest $request, $id)
{
$car = Car::findOrFail($id);
$car->update($request->all());
return response()->json($car, 200);
}
public function destroy($id)
{
Car::destroy($id);
return response()->json(null, 204);
}
}
angular2
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class CarRequest extends FormRequest
{
public function authorize()
{
return true;
}
public function rules()
{
return [];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.