phpvms/resources/stubs/modules/controller-api.stub

39 lines
855 B
Plaintext
Raw Normal View History

<?php
namespace $MODULE_NAMESPACE$\$STUDLY_NAME$\Http\Controllers\Api;
2019-08-02 21:02:23 +08:00
use App\Contracts\Controller;
use Illuminate\Http\Request;
/**
2018-06-22 21:31:15 +08:00
* class ApiController
* @package $MODULE_NAMESPACE$\$STUDLY_NAME$\Http\Controllers\Api
*/
2018-06-22 21:31:15 +08:00
class ApiController extends Controller
{
/**
* Just send out a message
* @param Request $request
2018-06-22 21:31:15 +08:00
* @return mixed
*/
public function index(Request $request)
{
return $this->message('Hello, world!');
}
/**
2018-06-22 21:31:15 +08:00
* Handles /hello
* @param Request $request
2018-06-22 21:31:15 +08:00
* @return mixed
*/
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,
]);
}
}