Пример #1
0
            $todays_record[$i]['id'] = $i;
            $todays_record[$i]['username'] = $app->user->where('id', $today_order->user_id)->first()->username;
            $category = $app->categories->where('id', $today_order->category_id)->first();
            $todays_record[$i]['category_name'] = $category->name;
            $todays_record[$i]['amount'] = $category->amount;
            $i++;
        }
        $todays_record = json_decode(json_encode($todays_record));
        $app->render('admin/example.php', ['todays_record' => $todays_record]);
    } else {
        $app->render('admin/example.php');
    }
})->name('admin.example');
$app->post('/admin/example', $admin(), function () use($app) {
    $todays_record = '';
    $date = new Date();
    $app->admin_list->create(['day' => $date->getCurrentDay(), 'lunch_date' => $date->getCurrentDate(), 'mail_send' => true]);
    //get order list for today from history table
    $todays_order = $app->history->where('lunch_date', $date->getCurrentDate())->get();
    $i = 0;
    foreach ($todays_order as $today_order) {
        $todays_record[$i]['id'] = $i;
        $todays_record[$i]['username'] = $app->user->where('id', $today_order->user_id)->first()->username;
        $category = $app->categories->where('id', $today_order->category_id)->first();
        $todays_record[$i]['category_name'] = $category->name;
        $todays_record[$i]['amount'] = $category->amount;
        $i++;
    }
    $todays_record = json_decode(json_encode($todays_record));
    //send order list by mail to admin
    $auth = $app->auth;
Пример #2
0
<?php

use Lunchbox\Helpers\Date;
$app->get('/u/:username', function ($username) use($app) {
    $records = '';
    $date = new Date();
    $user = $app->user->where('username', $username)->first();
    if (!$user) {
        $app->notFound();
    }
    $history = $app->history->where('user_id', $user->id)->where('lunch_date', '>=', $date->getCurrentMonthFirstDay())->orderBy('lunch_date', 'DESC')->get();
    $i = 0;
    $serial_number = 1;
    foreach ($history as $day_history) {
        $records[$i]['id'] = $serial_number;
        $category = $app->categories->where('id', $day_history->category_id)->first();
        $records[$i]['category_name'] = $category->name;
        $records[$i]['amount'] = $category->amount;
        $records[$i]['date'] = $day_history->lunch_date;
        $i++;
        $serial_number++;
    }
    $records = json_decode(json_encode($records));
    $app->render('user/profile.php', ['user' => $user, 'records' => $records]);
})->name('user.profile');