47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin\Core;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use App\Repositories\Core\Comments;
|
|
use App\Datatables\Admin\Core\CommentsDataTable;
|
|
|
|
class CommentController extends Controller
|
|
{
|
|
public function index(CommentsDataTable $dataTable, $model, $model_id)
|
|
{
|
|
$data['model'] = $model;
|
|
$data['model_id'] = $model_id;
|
|
return $dataTable->render('Admin.Core.Comment.index', $data);
|
|
}
|
|
|
|
public function create($model, $model_id)
|
|
{
|
|
$data['comment']['commentable_type'] = $model;
|
|
$data['comment']['commentable_id'] = $model_id;
|
|
return view('Admin.Core.Comments.partials.modal', $data);
|
|
}
|
|
|
|
public function edit(Request $request, $id = false)
|
|
{
|
|
$id = $id ? $id : $request->input('id');
|
|
$data = Comments::get($id);
|
|
return view('Admin.Core.Comments.partials.modal', $data);
|
|
}
|
|
|
|
public function store(Request $request)
|
|
{
|
|
$data = $request->all();
|
|
Comments::store($data);
|
|
return response()->json(['error' => 0]);
|
|
}
|
|
|
|
public function destroy(Request $request, $id = false)
|
|
{
|
|
$id = $id ? $id : $request->input('id');
|
|
Comments::destroy($id);
|
|
return response()->json(['error' => 0]);
|
|
}
|
|
}
|