2018-04-19 05:55:58 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
2018-05-26 22:46:07 +00:00
|
|
|
use App\Jobs\StatusPipeline\NewStatusPipeline;
|
|
|
|
use Auth, Hashids;
|
2018-04-19 05:55:58 +00:00
|
|
|
use App\{Comment, Profile, Status};
|
|
|
|
|
|
|
|
class CommentController extends Controller
|
|
|
|
{
|
|
|
|
public function store(Request $request)
|
|
|
|
{
|
|
|
|
if(Auth::check() === false) { abort(403); }
|
|
|
|
$this->validate($request, [
|
2018-05-26 22:46:07 +00:00
|
|
|
'item' => 'required|integer',
|
2018-04-19 05:55:58 +00:00
|
|
|
'comment' => 'required|string|max:500'
|
|
|
|
]);
|
2018-05-26 22:46:07 +00:00
|
|
|
$comment = $request->input('comment');
|
|
|
|
$statusId = $request->item;
|
2018-04-19 05:55:58 +00:00
|
|
|
|
|
|
|
$user = Auth::user();
|
|
|
|
$profile = $user->profile;
|
|
|
|
$status = Status::findOrFail($statusId);
|
|
|
|
|
2018-05-26 22:46:07 +00:00
|
|
|
$reply = new Status();
|
|
|
|
$reply->profile_id = $profile->id;
|
|
|
|
$reply->caption = $comment;
|
|
|
|
$reply->rendered = $comment;
|
|
|
|
$reply->in_reply_to_id = $status->id;
|
|
|
|
$reply->in_reply_to_profile_id = $status->profile_id;
|
|
|
|
$reply->save();
|
|
|
|
|
|
|
|
NewStatusPipeline::dispatch($reply, false);
|
2018-04-19 05:55:58 +00:00
|
|
|
|
|
|
|
return redirect($status->url());
|
|
|
|
}
|
|
|
|
}
|