admin can add comments to PIREPs #70
This commit is contained in:
@@ -2,19 +2,24 @@
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Log;
|
||||
use Flash;
|
||||
use Response;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Prettus\Repository\Criteria\RequestCriteria;
|
||||
|
||||
use App\Services\PIREPService;
|
||||
|
||||
use App\Models\PirepComment;
|
||||
use App\Models\Enums\PirepState;
|
||||
|
||||
use App\Http\Requests\CreatePirepRequest;
|
||||
use App\Http\Requests\UpdatePirepRequest;
|
||||
use App\Models\Enums\PirepState;
|
||||
use App\Repositories\AircraftRepository;
|
||||
use App\Repositories\AirlineRepository;
|
||||
use App\Repositories\AirportRepository;
|
||||
use App\Repositories\PirepRepository;
|
||||
use App\Services\PIREPService;
|
||||
use Illuminate\Http\Request;
|
||||
use Flash;
|
||||
use Log;
|
||||
use Prettus\Repository\Criteria\RequestCriteria;
|
||||
use Response;
|
||||
use App\Facades\Utils;
|
||||
|
||||
|
||||
@@ -230,4 +235,36 @@ class PirepController extends BaseController
|
||||
$pirep->refresh();
|
||||
return view('admin.pireps.pirep_card', ['pirep' => $pirep]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a comment to the Pirep
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function comments($id, Request $request)
|
||||
{
|
||||
$user = Auth::user();
|
||||
$pirep = $this->pirepRepo->findWithoutFail($request->id);
|
||||
if ($request->isMethod('post')) {
|
||||
$comment = new PirepComment([
|
||||
'user_id' => $user->id,
|
||||
'pirep_id' => $pirep->id,
|
||||
'comment' => $request->get('comment'),
|
||||
]);
|
||||
|
||||
$comment->save();
|
||||
$pirep->refresh();
|
||||
}
|
||||
|
||||
if($request->isMethod('delete')) {
|
||||
$comment = PirepComment::find($request->get('comment_id'));
|
||||
$comment->delete();
|
||||
$pirep->refresh();
|
||||
}
|
||||
|
||||
return view('admin.pireps.comments', [
|
||||
'pirep' => $pirep,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,15 +87,20 @@ class UserController extends BaseController
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$users = $this->userRepo->findWithoutFail($id);
|
||||
$user = $this->userRepo->findWithoutFail($id);
|
||||
|
||||
if (empty($users)) {
|
||||
if (empty($user)) {
|
||||
Flash::error('User not found');
|
||||
return redirect(route('admin.users.index'));
|
||||
}
|
||||
|
||||
return view('admin.users.show', [
|
||||
'users' => $users,
|
||||
'user' => $user,
|
||||
'airlines' => Airline::all(),
|
||||
'timezones' => Timezonelist::toArray(),
|
||||
'airports' => Airport::all()->pluck('icao', 'id'),
|
||||
'ranks' => Rank::all()->pluck('name', 'id'),
|
||||
'roles' => Role::all()->pluck('name', 'id'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user