PHP code example of zamshed / crud-package-laravel
1. Go to this page and download the library: Download zamshed/crud-package-laravel 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/ */
angular2
namespace App\Http\Controllers;
use App\Http\Requests\PostRequest;
use App\Post;
class PostController extends Controller
{
public function index()
{
$posts = Post::latest()->get();
return response()->json($posts, 201);
}
public function store(PostRequest $request)
{
$post = Post::create($request->all());
return response()->json($post, 201);
}
public function show($id)
{
$post = Post::findOrFail($id);
return response()->json($post);
}
public function update(PostRequest $request, $id)
{
$post = Post::findOrFail($id);
$post->update($request->all());
return response()->json($Post, 200);
}
public function destroy($id)
{
Post::destroy($id);
return response()->json(null, 204);
}
}
angular2
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class PostRequest 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.