2018-02-09 09:09:36 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace $MODULE_NAMESPACE$\$STUDLY_NAME$\Http\Controllers\Api;
|
|
|
|
|
2019-08-02 21:02:23 +08:00
|
|
|
use App\Contracts\Controller;
|
2018-02-09 09:09:36 +08:00
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
2018-03-20 09:50:40 +08:00
|
|
|
/**
|
2018-06-22 21:31:15 +08:00
|
|
|
* class ApiController
|
2018-03-20 09:50:40 +08:00
|
|
|
* @package $MODULE_NAMESPACE$\$STUDLY_NAME$\Http\Controllers\Api
|
|
|
|
*/
|
2018-06-22 21:31:15 +08:00
|
|
|
class ApiController extends Controller
|
2018-02-09 09:09:36 +08:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Just send out a message
|
2020-09-21 07:10:52 +08:00
|
|
|
*
|
2018-02-09 09:09:36 +08:00
|
|
|
* @param Request $request
|
2020-09-21 07:10:52 +08:00
|
|
|
*
|
2018-06-22 21:31:15 +08:00
|
|
|
* @return mixed
|
2018-02-09 09:09:36 +08:00
|
|
|
*/
|
|
|
|
public function index(Request $request)
|
|
|
|
{
|
|
|
|
return $this->message('Hello, world!');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-06-22 21:31:15 +08:00
|
|
|
* Handles /hello
|
2020-09-21 07:10:52 +08:00
|
|
|
*
|
2018-02-09 09:09:36 +08:00
|
|
|
* @param Request $request
|
2020-09-21 07:10:52 +08:00
|
|
|
*
|
2018-06-22 21:31:15 +08:00
|
|
|
* @return mixed
|
2018-02-09 09:09:36 +08:00
|
|
|
*/
|
|
|
|
public function hello(Request $request)
|
|
|
|
{
|
|
|
|
// Another way to return JSON, this for a custom response
|
|
|
|
// It's recommended to use Resources for responses from the database
|
|
|
|
return response()->json([
|
|
|
|
'name' => Auth::user()->name,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|