Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Routes
- $app->get('/', function ($request, $response, $args) {
- // Sample log message
- $this->logger->info("Slim-Skeleton '/' route");
- // Render index view
- return $this->renderer->render($response, 'index.phtml', $args);
- });
- $app->get('/get-data', function($request, $response, $args){
- return Account::all()->toJson();
- });
- $app->post('/insert-data', function($request, $response, $args){
- $input = $request->getParsedBody();
- $account = new Account;
- $account->id = $input['id'];
- $account->username = $input['username'];
- $account->email = $input['email'];
- $account->password = $input['password'];
- $account->save();
- return $account->toJson();
- });
- $app->put('/update-data', function($request, $response, $args){
- $input = $request->getParsedBody();
- $find = Account::where('id', '=', $input['id'])->first();
- $find->username = $input['username'];
- $find->email = $input['email'];
- $find->password = $input['password'];
- $find->save();
- return $find->toJson();
- });
- $app->delete('/delete-data', function($request, $response, $args){
- $input = $request->getParsedBody();
- $find = Account::where('id', '=', $input['id'])->first();
- $find->delete();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement