bug fixes, daily reports, holidays
This commit is contained in:
42
app/Http/Controllers/DailyReportController.php
Normal file
42
app/Http/Controllers/DailyReportController.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\DailyReport;
|
||||
use App\Models\ReportOverride;
|
||||
use App\Http\Requests\StoreDailyReportRequest;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\DailyReportSubmitted;
|
||||
|
||||
class DailyReportController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$reports = auth()->user()->dailyReports()
|
||||
->orderBy('report_date', 'desc')
|
||||
->paginate(15);
|
||||
|
||||
return view('reports.index', compact('reports'));
|
||||
}
|
||||
public function store(StoreDailyReportRequest $request)
|
||||
{
|
||||
$report = DailyReport::create([
|
||||
'user_id' => auth()->id(),
|
||||
'report_date' => $request->report_date,
|
||||
'content' => $request->content,
|
||||
]);
|
||||
|
||||
// If they used an override, optionally delete or mark it as used so it can't be reused
|
||||
ReportOverride::where('user_id', auth()->id())
|
||||
->where('report_date', $request->report_date)
|
||||
->delete();
|
||||
|
||||
$managementEmails = ['samuel@click-mobile.com'];
|
||||
Mail::to($managementEmails)->send(new DailyReportSubmitted($report, auth()->user()));
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Daily report submitted successfully.'
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user