2018-06-10 10:04:03 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
|
|
|
|
use App\Http\Requests\Api\TopicRequest;
|
|
|
|
use App\Models\Topic;
|
|
|
|
use App\Transformers\TopicTransformer;
|
|
|
|
|
|
|
|
class TopicsController extends Controller
|
|
|
|
{
|
|
|
|
public function store(TopicRequest $request, Topic $topic)
|
|
|
|
{
|
|
|
|
$topic->fill($request->all());
|
|
|
|
$topic->user_id = $this->user()->id;
|
|
|
|
$topic->save();
|
|
|
|
return $this->response->item($topic, new TopicTransformer())->setStatusCode(201);
|
|
|
|
}
|
2018-06-10 10:35:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param TopicRequest $request
|
|
|
|
* @param Topic $topic
|
|
|
|
* @return \Dingo\Api\Http\Response
|
|
|
|
* @throws \Illuminate\Auth\Access\AuthorizationException
|
|
|
|
*/
|
|
|
|
public function update(TopicRequest $request, Topic $topic)
|
|
|
|
{
|
|
|
|
$this->authorize('update', $topic);
|
|
|
|
$topic->update($request->all());
|
|
|
|
return $this->response->item($topic, new TopicTransformer());
|
|
|
|
}
|
2018-06-10 10:04:03 +00:00
|
|
|
}
|