Generic-University icon indicating copy to clipboard operation
Generic-University copied to clipboard

Add additional interesting endpoints

Open InsiderPhD opened this issue 4 years ago • 0 comments

The endpoints currently focus on grades, classes, user and roles, it might be interesting to add some more to better flush out the application, plus gives more to brute force. The controllers presently have easy copy and paste functionality to add the RESTful endpoints

    private $model = UniClass::class;

    public function __construct()
    {
        $this->model = \App::make($this->model);
    }

    function index()
    {
        return $this->model::all();
    }

    function store(Request $request)
    {
        return $this->model->create($request->input());
    }

    function show($id)
    {
        return $this->model->find($id);
    }

    function update(Request $request, $id)
    {

        if ($model = $this->model->find($id)) {
            $model->update($request->input());
            return $model;
        }
        return json_encode('Resource: ' . $id . ' with presented ID does not exist.');
    }

    function destroy($id)
    {
        $this->model->destroy($id);
    }

InsiderPhD avatar Jun 07 '20 21:06 InsiderPhD