<?php
namespace App\Http\Controllers;
use App\Models\Log;
use DateTime;
use Illuminate\Http\Request;
class LogUserController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index(Request $request)
{
//
// dd($request->query('nama_pelanggan'));
$begin = new DateTime('-1 month');
$end = new DateTime();
$periode = [
$begin->format('d/m/Y'),
$end->format('d/m/Y'),
];
if (request()->periode) {
$periode = explode(" - ", request()->periode);
$begin = DateTime::createFromFormat('d/m/Y', $periode[0]);
$end = DateTime::createFromFormat('d/m/Y', $periode[1]);
}
// dd(request()->periode, $begin->format('Y-m-d'), $end->format('Y-m-d'));
$aksi = $request->query('aksi');
$datas = Log::with('pengguna')
->where(function($w)use($aksi){
$w->where('action', 'LIKE', '%'.$aksi.'%')->orwhere('action_detail', 'LIKE', '%'.$aksi.'%');
});
if (request()->periode) {
$datas = $datas->whereBetween('created_at', [$begin->format('Y-m-d')." 00:00:00", $end->format('Y-m-d')." 23:59:59"]);
}
$datas = $datas->latest()->paginate(10);
// $Logs = $Logs->paginate(10);
return view('log.index', compact('datas', 'periode', 'aksi'));
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*/
public function show(string $id)
{
//
}
/**
* Show the form for editing the specified resource.
*/
public function edit(string $id)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, string $id)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(string $id)
{
//
}
}
Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]