2018-02-09 09:09:36 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Modules\Sample\Http\Controllers\Api;
|
|
|
|
|
2019-07-16 03:44:31 +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
|
|
|
/**
|
|
|
|
* Class SampleController
|
|
|
|
*/
|
|
|
|
class SampleController extends Controller
|
2018-02-09 09:09:36 +08:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Just send out a message
|
2019-08-27 00:32:46 +08:00
|
|
|
*
|
2018-02-09 09:09:36 +08:00
|
|
|
* @param Request $request
|
2019-08-27 00:32:46 +08:00
|
|
|
*
|
2018-03-20 09:50:40 +08:00
|
|
|
* @return \Illuminate\Http\JsonResponse
|
2018-02-09 09:09:36 +08:00
|
|
|
*/
|
|
|
|
public function index(Request $request)
|
|
|
|
{
|
|
|
|
return $this->message('Hello, world!');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Request $request
|
2019-08-27 00:32:46 +08:00
|
|
|
*
|
2018-03-20 09:50:40 +08:00
|
|
|
* @return \Illuminate\Http\JsonResponse
|
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,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|