Created
March 9, 2019 08:20
-
-
Save earth774/5043d48e0599da86b9a420cc682eb818 to your computer and use it in GitHub Desktop.
UserController.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use Illuminate\Http\Response; | |
class UserController extends Controller | |
{ | |
/** | |
* Create a new controller for User. | |
* | |
* @return void | |
*/ | |
public function __construct() | |
{ | |
// | |
} | |
public function getAll() | |
{ | |
return $this->responseSuccess('Get All Data'); | |
} | |
public function getID($id) | |
{ | |
return $this->responseSuccess('Get ID Data' . $id); | |
} | |
public function addData() | |
{ | |
return $this->responseSuccess('Add Data'); | |
} | |
public function updateData($id) | |
{ | |
return $this->responseSuccess('Update Data' . $id); | |
} | |
public function deleteData($id) | |
{ | |
return $this->responseSuccess('Delete Data' . $id); | |
} | |
protected function responseSuccess($res) | |
{ | |
return response()->json(["status" => "success", "data" => $res], 200) | |
->header("Access-Control-Allow-Origin", "*") | |
->header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment