Skip to content

Instantly share code, notes, and snippets.

@earth774
Created March 9, 2019 08:20
Show Gist options
  • Save earth774/5043d48e0599da86b9a420cc682eb818 to your computer and use it in GitHub Desktop.
Save earth774/5043d48e0599da86b9a420cc682eb818 to your computer and use it in GitHub Desktop.
UserController.php
<?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