Correction of the notification route and Fag.
This commit is contained in:
parent
3ff091ca12
commit
c233f7ad25
@ -7,11 +7,13 @@ namespace App\Http\Controllers;
|
||||
use App\Http\Resources\EconomyResource;
|
||||
use App\Repositories\Economy\EconomyContractInterface;
|
||||
use App\Traits\ApiResponse;
|
||||
use Carbon\Carbon;
|
||||
use DateInterval;
|
||||
use DatePeriod;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class EconomyController extends Controller
|
||||
{
|
||||
@ -78,7 +80,7 @@ class EconomyController extends Controller
|
||||
try {
|
||||
$response = $this->economyContract->getCostMWhEconomy($request->all());
|
||||
|
||||
$res = static::checkDate();
|
||||
$res = static::checkDate($response);
|
||||
|
||||
dd($res);
|
||||
|
||||
@ -90,22 +92,58 @@ class EconomyController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public static function checkDate(){
|
||||
$start_date = date_create("2021-04-01");
|
||||
$end_date = date_create("2022-03-01"); // If you want to include this date, add 1 day
|
||||
public static function checkDate($value)
|
||||
{
|
||||
$start_date = current( $value);
|
||||
|
||||
$interval = DateInterval::createFromDateString('1 months');
|
||||
$daterange = new DatePeriod($start_date, $interval ,$end_date);
|
||||
dd($start_date);
|
||||
|
||||
$res = [];
|
||||
foreach($daterange as $date1){
|
||||
|
||||
if (!'02/2022' )
|
||||
|
||||
$res[] = $date1->format('m/Y');
|
||||
$y = [];
|
||||
foreach ($value as $val) {
|
||||
$te = explode('/', $val->mes);
|
||||
unset($te[0]);
|
||||
$y[] = $te[1];
|
||||
}
|
||||
|
||||
return $res;
|
||||
$val = collect($y)->unique();
|
||||
|
||||
$start_date = date_create("2021-01-01");
|
||||
$end_date = date_create("2022-03-30"); // If you want to include this date, add 1 day
|
||||
|
||||
$interval = DateInterval::createFromDateString('1 months');
|
||||
$daterange = new DatePeriod($start_date, $interval, $end_date);
|
||||
|
||||
$date = [];
|
||||
foreach ($daterange as $date1) {
|
||||
$date[] = $date1->format('m/Y');
|
||||
}
|
||||
|
||||
$arr = collect($value)->toArray();
|
||||
|
||||
$i = 0;
|
||||
foreach ($date as $dt) {
|
||||
if (empty($arr[$i])){
|
||||
$arr[] = ['mes' => $dt];
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
sort($arr);
|
||||
|
||||
dd($arr);
|
||||
|
||||
// if (!in_array($dt, $arr[$i], true)) {
|
||||
// $res[] = $dt;
|
||||
// } else {
|
||||
// $res[] = $arr[$i];
|
||||
// }
|
||||
|
||||
|
||||
dd($arr);
|
||||
|
||||
|
||||
dd($arr, $date);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -19,10 +19,24 @@ Route::prefix('auth')->group(function (){
|
||||
Route::post('logout', [\App\Http\Controllers\Auth\AuthController::class, 'logout']);
|
||||
});
|
||||
|
||||
Route::middleware(['auth:sanctum', 'verified'])->group(function () {
|
||||
Route::get('notification', [\App\Http\Controllers\NotificationController::class, 'index']);
|
||||
Route::get('notification/{notification}', [\App\Http\Controllers\NotificationController::class, 'show']);
|
||||
|
||||
Route::get('faq', [\App\Http\Controllers\FaqController::class, 'index']);
|
||||
Route::get('faq/{faq}', [\App\Http\Controllers\FaqController::class, 'show']);
|
||||
});
|
||||
|
||||
Route::middleware(['auth:sanctum', 'ability:Admin'])->group(function () {
|
||||
Route::apiResource('user', \App\Http\Controllers\UserController::class);
|
||||
Route::apiResource('notification', \App\Http\Controllers\NotificationController::class);
|
||||
Route::apiResource('faq', \App\Http\Controllers\FaqController::class);
|
||||
|
||||
Route::put('notification', [\App\Http\Controllers\NotificationController::class, 'update']);
|
||||
Route::post('notification', [\App\Http\Controllers\NotificationController::class, 'store']);
|
||||
Route::delete('notification', [\App\Http\Controllers\NotificationController::class, 'destroy']);
|
||||
|
||||
Route::put('faq', [\App\Http\Controllers\FaqController::class, 'update']);
|
||||
Route::post('faq', [\App\Http\Controllers\FaqController::class, 'store']);
|
||||
Route::delete('faq', [\App\Http\Controllers\FaqController::class, 'destroy']);
|
||||
});
|
||||
|
||||
Route::middleware(['auth:sanctum', 'ability:Client'])->group(function () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user