File: /var/www/vhost/disk-apps/comfama.sports-crowd.com/app/Http/Controllers/ChangelogsController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Log;
use App\Changelog;
use Datatables;
class ChangelogsController extends Controller
{
public function index()
{
$rol = Auth::user()->rol->id;
return view('changelogs.changelogs')->with('rol', $rol);
}
public function indexAdd()
{
return view('changelogs.addChangelog');
}
public function create(Request $request)
{
$changelog = new Changelog();
$changelog->title = $request["title"];
$changelog->description = $request["description"];
$changelog->save(); //Guarda el nuevo objeto
$logObject = $changelog;
$this->registerLog(Auth::user()->id, 'Creó un changelog', json_encode($logObject), "Create", 5);
if ($changelog) {
return array('r' => true, 'd' => null, 'm' => trans('messages.screen_changelogs_tag8'));
} else {
return array('r' => false, 'd' => null, 'm' => trans('messages.screen_changelogs_tag9'));
}
}
public function tableFilter()
{
$logs = Log::with(['user', 'module'])->orderBy('id', 'DESC');
return Datatables::of($logs)
->editColumn('data_operation', function ($logs) {
return '<pre id="json' . $logs->id . '">' . $logs->data_operation . '</pre>';
})
->rawColumns(['data_operation'])
->make(true);
}
}