Merge branch 'issue-2' into 'develop'
Issue 2 Les carbon format() deviennent isoFormat() Closes #2 and #3 See merge request ldc-web/projets/crm!6
This commit is contained in:
commit
332ded505d
18 changed files with 194 additions and 110 deletions
102
app/Console/Commands/CreateAdmin.php
Normal file
102
app/Console/Commands/CreateAdmin.php
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
/**
|
||||
* Creates a new user
|
||||
*/
|
||||
class CreateAdmin extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'user:create';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a backend admin user';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$email = null;
|
||||
while (is_null($email)) {
|
||||
try {
|
||||
$tmp = $this->ask('Type the wanted user email', 'equipe.web@ldc.fr');
|
||||
$validator = Validator::make(['email' => $tmp], [
|
||||
'email' => 'required|unique:users,email|email:rfc,dns'
|
||||
]);
|
||||
$validator->validate();
|
||||
$email = $tmp;
|
||||
} catch (ValidationException $e) {
|
||||
$this->error(sprintf(
|
||||
'Please provide a valid email %s',
|
||||
\implode(',', collect($e->errors())->flatten()->all())
|
||||
));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$firstname = null;
|
||||
while (is_null($firstname)) {
|
||||
try {
|
||||
$tmp = $this->ask('Type the wanted user firstname', 'Admin');
|
||||
$validator = Validator::make(['firstname' => $tmp], [
|
||||
'firstname' => 'required|min:5,max:255'
|
||||
]);
|
||||
$validator->validate();
|
||||
$firstname = $tmp;
|
||||
} catch (ValidationException $e) {
|
||||
$this->error(sprintf(
|
||||
'Please provide a valid firstname %s',
|
||||
\implode(',', collect($e->errors())->flatten()->all())
|
||||
));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$lastname = null;
|
||||
while (is_null($lastname)) {
|
||||
try {
|
||||
$tmp = $this->ask('Type the wanted user lastname', 'Saïtama');
|
||||
$validator = Validator::make(['lastname' => $tmp], [
|
||||
'lastname' => 'required|min:5,max:255'
|
||||
]);
|
||||
$validator->validate();
|
||||
$lastname = $tmp;
|
||||
} catch (ValidationException $e) {
|
||||
$this->error(sprintf(
|
||||
'Please provide a valid lastname %s',
|
||||
\implode(',', collect($e->errors())->flatten()->all())
|
||||
));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$password = $this->secret('Type the wanted user password');
|
||||
|
||||
$admin = new User([
|
||||
'lastname' => $lastname,
|
||||
'firstname' => $firstname,
|
||||
'email' => $email,
|
||||
'password' => $password
|
||||
]);
|
||||
$admin->saveOrFail();
|
||||
|
||||
$this->info('User created.');
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class UserCreate extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'user:create';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$firstname = $this->ask('What is the firstname?');
|
||||
$lastname = $this->ask('What is the lastname?');
|
||||
$email = $this->ask('What is the email?');
|
||||
$pwd = $this->secret('What is the password?');
|
||||
|
||||
$user = new User();
|
||||
$user->firstname = $firstname;
|
||||
$user->lastname = $lastname;
|
||||
$user->email = $email;
|
||||
$user->password = Hash::make($pwd);
|
||||
$user->save();
|
||||
|
||||
$this->info('User created.');
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -71,7 +71,7 @@ class StatsController extends Controller
|
|||
->get()->map(function ($custAnswer) {
|
||||
return [
|
||||
'answer_id' => $custAnswer->answer_id,
|
||||
'created_at' => $custAnswer->created_at->format('Y-m-d'),
|
||||
'created_at' => $custAnswer->created_at->isoFormat('YYYY-MM-DD'),
|
||||
];
|
||||
})->groupBy(['created_at', 'answer_id'])->map(function ($day) {
|
||||
return $day->map(function ($custAnswers) {
|
||||
|
|
@ -80,7 +80,7 @@ class StatsController extends Controller
|
|||
});
|
||||
|
||||
do {
|
||||
$currentDate = $start->format('Y-m-d');
|
||||
$currentDate = $start->isoFormat('YYYY-MM-DD');
|
||||
/** @var \Illuminate\Support\Collection $answersByDays */
|
||||
if (!$answersByDays->has($currentDate)) {
|
||||
$answersByDays->put(
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ class CustomerController extends Controller
|
|||
'Content-Disposition',
|
||||
sprintf(
|
||||
'attachment; filename="Export pour newsletter %s %s.csv"',
|
||||
Carbon::now()->format('d-m-Y_H-i'),
|
||||
Carbon::now()->isoFormat('DD-MM-YYYY_HH-mm'),
|
||||
Str::slug($exportType)
|
||||
)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ class QuestionController extends Controller
|
|||
'Content-Disposition',
|
||||
sprintf(
|
||||
'attachment; filename="Export pour newsletter %s %s.csv"',
|
||||
Carbon::now()->format('d-m-Y_H-i'),
|
||||
Carbon::now()->isoFormat('DD-MM-YYYY_HH-mm'),
|
||||
Str::slug($brand->name)
|
||||
)
|
||||
);
|
||||
|
|
@ -248,6 +248,13 @@ class QuestionController extends Controller
|
|||
$w->insertOne([]);
|
||||
}
|
||||
|
||||
// * Push empty line if nothing to export
|
||||
if (empty($results)) {
|
||||
$w->insertOne([
|
||||
'Aucune question pour cette marque'
|
||||
]);
|
||||
}
|
||||
|
||||
/*
|
||||
We create a callable to output the CSV in chunk
|
||||
with Symfony StreamResponse you can flush the body content if necessary
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class StatsController extends Controller
|
|||
|
||||
foreach ($stats as $stat) {
|
||||
$cols = [
|
||||
$stat->created_at->format('Y-m-d'),
|
||||
$stat->created_at->isoFormat('YYYY-MM-DD'),
|
||||
$stat->brand->name
|
||||
];
|
||||
foreach ($columns as $colname) {
|
||||
|
|
@ -161,7 +161,7 @@ class StatsController extends Controller
|
|||
->get()->map(function ($custAnswer) {
|
||||
return [
|
||||
'answer_id' => $custAnswer->answer_id,
|
||||
'created_at' => $custAnswer->created_at->format('Y-m-d'),
|
||||
'created_at' => $custAnswer->created_at->isoFormat('YYYY-MM-DD'),
|
||||
];
|
||||
})->groupBy(['created_at', 'answer_id'])->map(function ($day) {
|
||||
return $day->map(function ($custAnswers) {
|
||||
|
|
@ -170,7 +170,7 @@ class StatsController extends Controller
|
|||
});
|
||||
|
||||
do {
|
||||
$currentDate = $start->format('Y-m-d');
|
||||
$currentDate = $start->isoFormat('YYYY-MM-DD');
|
||||
/** @var \Illuminate\Support\Collection $answersByDays */
|
||||
if (!$answersByDays->has($currentDate)) {
|
||||
$answersByDays->put(
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class BrandStatsResource extends JsonResourceCollection
|
|||
return [
|
||||
'stats' => $this->collection->map(function (BrandStat $brandStat) {
|
||||
return [
|
||||
'date' => $brandStat->created_at->format('Y-m-d'),
|
||||
'date' => $brandStat->created_at->isoFormat('YYYY-MM-DD'),
|
||||
'active' => $brandStat->active,
|
||||
'inactive' => $brandStat->inactive,
|
||||
'old_accounts' => $brandStat->old_accounts,
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ namespace App\Models;
|
|||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
|
|
@ -17,7 +19,8 @@ class User extends Authenticatable
|
|||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'lastname',
|
||||
'firstname',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
|
@ -40,4 +43,26 @@ class User extends Authenticatable
|
|||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* Perform any actions required after the model boots.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function booted()
|
||||
{
|
||||
// * EVENT CLOSURES.
|
||||
static::creating(function (self $model) {
|
||||
if (Hash::needsRehash($model->password)) {
|
||||
$model->password = Hash::make($model->password);
|
||||
}
|
||||
$model->remember_token = Str::random(10);
|
||||
});
|
||||
static::updating(function (self $model) {
|
||||
if (Hash::needsRehash($model->password)) {
|
||||
$model->password = Hash::make($model->password);
|
||||
}
|
||||
$model->remember_token = Str::random(10);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class RepairStatsJobs extends Migration
|
|||
$ref->setAccessible(true);
|
||||
$service = $ref->getValue(unserialize($payload->data->command));
|
||||
|
||||
$date = Carbon::parse($job->created_at)->format('Y-m-d');
|
||||
$date = Carbon::parse($job->created_at)->isoFormat('YYYY-MM-DD');
|
||||
|
||||
$serviceStat = ServiceStat::whereDate('date', $date)
|
||||
->where('service_id', $service->id)->where('brand_id', $service->brand->id)
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td><b>{{ __('Date de naissance') }}</b></td>
|
||||
<td>{{ \Carbon\Carbon::parse($customerInfos->birth_date)->format('d/m/Y') }}</td>
|
||||
<td>{{ \Carbon\Carbon::parse($customerInfos->birth_date)->isoFormat('DD\/MM\/YYYY') }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>{{ __('Téléphone') }}</b></td>
|
||||
|
|
@ -96,14 +96,14 @@
|
|||
<tr>
|
||||
<td><b>{{ __('Date de la dernière modification de l\'abonnement') }}</b></td>
|
||||
@if($customerInfos->customer->optInHistory()->orderBy('created_at', 'DESC')->exists())
|
||||
<td>{{ \Carbon\Carbon::parse($customerInfos->customer->optInHistory()->orderBy('created_at', 'DESC')->first()->created_at)->format('d/m/Y à H:i') }}</td>
|
||||
<td>{{ \Carbon\Carbon::parse($customerInfos->customer->optInHistory()->orderBy('created_at', 'DESC')->first()->created_at)->isoFormat('DD\/MM\/YYYY à HH:mm') }}</td>
|
||||
@else
|
||||
<td></td>
|
||||
@endif
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>{{ __('Dernière connexion') }}</b></td>
|
||||
<td>{{ \Carbon\Carbon::parse($customerLogin->last_connection)->format('d/m/Y à H:i') }}</td>
|
||||
<td>{{ \Carbon\Carbon::parse($customerLogin->last_connection)->isoFormat('DD\/MM\/YYYY à HH:mm') }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>{{ __('Status du compte') }}</b></td>
|
||||
|
|
@ -115,11 +115,11 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td><b>{{ __('Date de création') }}</b></td>
|
||||
<td>{{ \Carbon\Carbon::parse($customerInfos->created_at)->format('d/m/Y à H:i') }}</td>
|
||||
<td>{{ \Carbon\Carbon::parse($customerInfos->created_at)->isoFormat('DD\/MM\/YYYY à HH:mm') }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>{{ __('Date de modification') }}</b></td>
|
||||
<td>{{ \Carbon\Carbon::parse($customerInfos->updated_at)->format('d/m/Y à H:i') }}</td>
|
||||
<td>{{ \Carbon\Carbon::parse($customerInfos->updated_at)->isoFormat('DD\/MM\/YYYY à HH:mm') }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<export_arcadia>
|
||||
<Commande>
|
||||
<Num_Commande>{{ $request->order_num }}</Num_Commande>
|
||||
<Date_Commande>{{ \Carbon::parse($request->order_date)->format('d/m/Y') }}</Date_Commande>
|
||||
<Date_Commande>{{ Carbon::parse($request->order_date)->isoFormat('DD\/MM\/YYYY') }}</Date_Commande>
|
||||
<Operation>{{ $request->operation }}</Operation>
|
||||
@if($type->equals(\App\Enums\ArcadiaMailType::default()))
|
||||
@if($orderType->equals(\App\Enums\ArcadiaOrderType::cb()))
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<export_arcadia>
|
||||
<Commande>
|
||||
<Num_Commande/>
|
||||
<Date_Commande>{{ \Carbon::parse($request->order_date)->format('d/m/Y') }}</Date_Commande>
|
||||
<Date_Commande>{{ Carbon::parse($request->order_date)->isoFormat('DD\/MM\/YYYY') }}</Date_Commande>
|
||||
<Operation>{{ $request->operation }}</Operation>
|
||||
<Email_conso><![CDATA[{{ $customerInfo['email'] }}]]></Email_conso>
|
||||
<Civilite/>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@
|
|||
|
||||
Un service vient d'être régénéré sur {{ $appName }}
|
||||
{{ $service->name }} (marque : {{ $service->brand->name }})
|
||||
Régénéré le {{ $service->updated_at->format('D/m/Y H:i') }}
|
||||
Régénéré le {{ $service->updated_at->isoFormat('dddd DD\/MM\/YYYY HH:MM') }}
|
||||
par {{ $by }}
|
||||
Celà va empêcher le service de fonctionner tant que les crédentials d'api n'auront pas été mis à jour sur le service concerné, veuillez faire au plus vite !
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<body>
|
||||
<h1>Un service vient d'être régénéré sur {{ $appName }}</h1>
|
||||
<h2>{{ $service->name }} (marque : {{ $service->brand->name }})</h2>
|
||||
<h3>Régénéré le {{ $service->updated_at->format('D d/m/Y H:i') }} <br> par {{ $by }}</h3>
|
||||
<h3>Régénéré le {{ $service->updated_at->isoFormat('dddd DD\/MM\/YYYY HH:MM') }} <br> par {{ $by }}</h3>
|
||||
<p><b>Celà va empêcher le service de fonctionner</b> tant que les crédentials d'api n'auront pas été mis à jour sur le service concerné, veuillez faire au plus vite !</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@
|
|||
<button class="btn btn-secondary date month" type="button">{{ __('Ce mois-ci') }}</button>
|
||||
<button class="btn btn-secondary date year" type="button">{{ __('Cette année') }}</button>
|
||||
<span class="input-group-text">{{ __('Début') }}</span>
|
||||
<input type="date" class="form-control date start" name="start" value="{{ request()->start ?? Carbon::now()->startOfMonth()->format('Y-m-d') }}" required>
|
||||
<input type="date" class="form-control date start" name="start" value="{{ request()->start ?? Carbon::now()->startOfMonth()->isoFormat('YYYY-MM-DD') }}" required>
|
||||
<span class="input-group-text">{{ __('Fin') }}</span>
|
||||
<input type="date" class="form-control date end" name="end" value="{{ request()->end ?? Carbon::now()->endOfMonth()->format('Y-m-d') }}" required>
|
||||
<input type="date" class="form-control date end" name="end" value="{{ request()->end ?? Carbon::now()->endOfMonth()->isoFormat('YYYY-MM-DD') }}" required>
|
||||
<select name="brand" class="form-select" required>
|
||||
<option value="" @if(!request()->brand) selected @endif>{{ __('Sélectionnez une marque') }}</option>
|
||||
@foreach(\App\Models\Brand::all() as $brand)
|
||||
|
|
@ -124,7 +124,7 @@
|
|||
label: 'actifs',
|
||||
borderColor: colors.active,
|
||||
data: @json($stats->map(function($brandStat) {
|
||||
return ['y' => $brandStat->active, 'x' => $brandStat->created_at->format('Y-m-d')];
|
||||
return ['y' => $brandStat->active, 'x' => $brandStat->created_at->isoFormat('YYYY-MM-DD')];
|
||||
})),
|
||||
fill: false,
|
||||
cubicInterpolationMode: 'monotone',
|
||||
|
|
@ -133,7 +133,7 @@
|
|||
label: 'inactifs',
|
||||
borderColor: colors.inactive,
|
||||
data: @json($stats->map(function($brandStat) {
|
||||
return ['y' => $brandStat->inactive, 'x' => $brandStat->created_at->format('Y-m-d')];
|
||||
return ['y' => $brandStat->inactive, 'x' => $brandStat->created_at->isoFormat('YYYY-MM-DD')];
|
||||
})),
|
||||
fill: false,
|
||||
cubicInterpolationMode: 'monotone',
|
||||
|
|
@ -142,7 +142,7 @@
|
|||
label: 'vieux comptes',
|
||||
borderColor: colors.old_accounts,
|
||||
data: @json($stats->map(function($brandStat) {
|
||||
return ['y' => $brandStat->old_accounts, 'x' => $brandStat->created_at->format('Y-m-d')];
|
||||
return ['y' => $brandStat->old_accounts, 'x' => $brandStat->created_at->isoFormat('YYYY-MM-DD')];
|
||||
})),
|
||||
fill: false,
|
||||
cubicInterpolationMode: 'monotone',
|
||||
|
|
@ -151,7 +151,7 @@
|
|||
label: 'nouveaux comptes',
|
||||
borderColor: colors.new_accounts,
|
||||
data: @json($stats->map(function($brandStat) {
|
||||
return ['y' => $brandStat->new_accounts, 'x' => $brandStat->created_at->format('Y-m-d')];
|
||||
return ['y' => $brandStat->new_accounts, 'x' => $brandStat->created_at->isoFormat('YYYY-MM-DD')];
|
||||
})),
|
||||
fill: false,
|
||||
cubicInterpolationMode: 'monotone',
|
||||
|
|
@ -160,7 +160,7 @@
|
|||
label: 'total comptes',
|
||||
borderColor: colors.total_accounts,
|
||||
data: @json($stats->map(function($brandStat) {
|
||||
return ['y' => $brandStat->total_accounts, 'x' => $brandStat->created_at->format('Y-m-d')];
|
||||
return ['y' => $brandStat->total_accounts, 'x' => $brandStat->created_at->isoFormat('YYYY-MM-DD')];
|
||||
})),
|
||||
fill: true,
|
||||
cubicInterpolationMode: 'monotone',
|
||||
|
|
@ -169,7 +169,7 @@
|
|||
label: 'total optins',
|
||||
borderColor: colors.total_opt_in,
|
||||
data: @json($stats->map(function($brandStat) {
|
||||
return ['y' => $brandStat->total_opt_in, 'x' => $brandStat->created_at->format('Y-m-d')];
|
||||
return ['y' => $brandStat->total_opt_in, 'x' => $brandStat->created_at->isoFormat('YYYY-MM-DD')];
|
||||
})),
|
||||
fill: false,
|
||||
cubicInterpolationMode: 'monotone',
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@
|
|||
<button class="btn btn-secondary date month" type="button">{{ __('Ce mois-ci') }}</button>
|
||||
<button class="btn btn-secondary date year" type="button">{{ __('Cette année') }}</button>
|
||||
<span class="input-group-text">{{ __('Début') }}</span>
|
||||
<input type="date" class="form-control date start" name="start" value="{{ request()->start ?? \Carbon::now()->startOfMonth()->format('Y-m-d') }}" required>
|
||||
<input type="date" class="form-control date start" name="start" value="{{ request()->start ?? Carbon::now()->startOfMonth()->isoFormat('YYYY-MM-DD') }}" required>
|
||||
<span class="input-group-text">{{ __('Fin') }}</span>
|
||||
<input type="date" class="form-control date end" name="end" value="{{ request()->end ?? \Carbon::now()->endOfMonth()->format('Y-m-d') }}" required>
|
||||
<input type="date" class="form-control date end" name="end" value="{{ request()->end ?? Carbon::now()->endOfMonth()->isoFormat('YYYY-MM-DD') }}" required>
|
||||
<select name="question" class="form-select" required>
|
||||
<option value="" @if(!request()->question) selected @endif>{{ __('Sélectionnez une question') }}</option>
|
||||
@foreach(\App\Models\Question::all() as $question)
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ class StatsTest extends ApiBase
|
|||
$service = Service::firstOrFail();
|
||||
|
||||
$response = $this->callApiWithToken($service, 'get', route('apiV2.stats.brandStats'), [
|
||||
'start' => Carbon::now()->subMonths(3)->format('Y-m-d'),
|
||||
'end' => Carbon::now()->format('Y-m-d')
|
||||
'start' => Carbon::now()->subMonths(3)->isoFormat('YYYY-MM-DD'),
|
||||
'end' => Carbon::now()->isoFormat('YYYY-MM-DD')
|
||||
]);
|
||||
|
||||
$json = $response->decodeResponseJson();
|
||||
|
|
@ -60,8 +60,8 @@ class StatsTest extends ApiBase
|
|||
$service = Service::firstOrFail();
|
||||
|
||||
$response = $this->callApiWithToken($service, 'get', route('apiV2.stats.brandStats'), [
|
||||
'start' => Carbon::now()->subMonths(3)->subDay()->format('Y-m-d'),
|
||||
'end' => Carbon::now()->format('Y-m-d')
|
||||
'start' => Carbon::now()->subMonths(3)->subDay()->isoFormat('YYYY-MM-DD'),
|
||||
'end' => Carbon::now()->isoFormat('YYYY-MM-DD')
|
||||
]);
|
||||
|
||||
$json = $response->decodeResponseJson();
|
||||
|
|
@ -79,8 +79,8 @@ class StatsTest extends ApiBase
|
|||
$service = Service::firstOrFail();
|
||||
|
||||
$response = $this->callApiWithToken($service, 'get', route('apiV2.stats.brandStats'), [
|
||||
'start' => Carbon::now()->subMonths(3)->subDay()->format('Y-m-d h:iDD'),
|
||||
'end' => Carbon::now()->format('Y-m-d')
|
||||
'start' => Carbon::now()->subMonths(3)->subDay()->isoFormat('YYYY-MM-DD HH:mmDD'),
|
||||
'end' => Carbon::now()->isoFormat('YYYY-MM-DD')
|
||||
]);
|
||||
|
||||
$json = $response->decodeResponseJson();
|
||||
|
|
@ -111,14 +111,14 @@ class StatsTest extends ApiBase
|
|||
$custAnswer->saveOrFail();
|
||||
|
||||
$response = $this->callApiWithToken($service, 'get', route('apiV2.stats.questionStats', $question), [
|
||||
'start' => $start->format('Y-m-d'),
|
||||
'end' => $end->format('Y-m-d')
|
||||
'start' => $start->isoFormat('YYYY-MM-DD'),
|
||||
'end' => $end->isoFormat('YYYY-MM-DD')
|
||||
]);
|
||||
|
||||
$datesIndexes = [];
|
||||
|
||||
do {
|
||||
$datesIndexes[$start->format('Y-m-d')] = $answersIds
|
||||
$datesIndexes[$start->isoFormat('YYYY-MM-DD')] = $answersIds
|
||||
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
||||
->keys()->all();
|
||||
|
||||
|
|
@ -151,8 +151,8 @@ class StatsTest extends ApiBase
|
|||
$question = Question::where('brand_id', '!=', $service->brand->id)->firstOrFail();
|
||||
|
||||
$response = $this->callApiWithToken($service, 'get', route('apiV2.stats.questionStats', $question), [
|
||||
'start' => Carbon::now()->subMonths(3)->subDay()->format('Y-m-d'),
|
||||
'end' => Carbon::now()->format('Y-m-d')
|
||||
'start' => Carbon::now()->subMonths(3)->subDay()->isoFormat('YYYY-MM-DD'),
|
||||
'end' => Carbon::now()->isoFormat('YYYY-MM-DD')
|
||||
]);
|
||||
|
||||
$json = $response->decodeResponseJson();
|
||||
|
|
@ -171,8 +171,8 @@ class StatsTest extends ApiBase
|
|||
$question = Question::whereBrandId($service->brand->id)->firstOrFail();
|
||||
|
||||
$response = $this->callApiWithToken($service, 'get', route('apiV2.stats.questionStats', $question), [
|
||||
'start' => Carbon::now()->subMonths(3)->subDay()->format('Y-m-d'),
|
||||
'end' => Carbon::now()->format('Y-m-d')
|
||||
'start' => Carbon::now()->subMonths(3)->subDay()->isoFormat('YYYY-MM-DD'),
|
||||
'end' => Carbon::now()->isoFormat('YYYY-MM-DD')
|
||||
]);
|
||||
|
||||
$json = $response->decodeResponseJson();
|
||||
|
|
@ -191,8 +191,8 @@ class StatsTest extends ApiBase
|
|||
$question = Question::whereBrandId($service->brand->id)->firstOrFail();
|
||||
|
||||
$response = $this->callApiWithToken($service, 'get', route('apiV2.stats.questionStats', $question), [
|
||||
'start' => Carbon::now()->subMonths(3)->format('Y-m Ddh'),
|
||||
'end' => Carbon::now()->format('Y-m-d')
|
||||
'start' => Carbon::now()->subMonths(3)->isoFormat('YYYY-MM Ddh'),
|
||||
'end' => Carbon::now()->isoFormat('YYYY-MM-DD')
|
||||
]);
|
||||
|
||||
$json = $response->decodeResponseJson();
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ class CrmClientV2StatsTest extends CrmClientTester
|
|||
$end = Carbon::now();
|
||||
|
||||
$stats = Stats::getBrandStats(
|
||||
$start->format('Y-m-d'),
|
||||
$end->format('Y-m-d')
|
||||
$start->isoFormat('YYYY-MM-DD'),
|
||||
$end->isoFormat('YYYY-MM-DD')
|
||||
);
|
||||
|
||||
$this->assertIsArray($stats, 'Results should be an array');
|
||||
|
|
@ -38,7 +38,7 @@ class CrmClientV2StatsTest extends CrmClientTester
|
|||
foreach ($keys as $key) {
|
||||
$this->assertArrayHasKey($key, $stats[$i]);
|
||||
}
|
||||
$this->assertEquals($start->format('Y-m-d'), $stats[$i++]['date']);
|
||||
$this->assertEquals($start->isoFormat('YYYY-MM-DD'), $stats[$i++]['date']);
|
||||
$start = $start->addDay();
|
||||
} while ($start->lessThanOrEqualTo($end));
|
||||
}
|
||||
|
|
@ -57,8 +57,8 @@ class CrmClientV2StatsTest extends CrmClientTester
|
|||
|
||||
try {
|
||||
Stats::getBrandStats(
|
||||
$start->format('Y-m-d'),
|
||||
$end->format('Y-m-d')
|
||||
$start->isoFormat('YYYY-MM-DD'),
|
||||
$end->isoFormat('YYYY-MM-DD')
|
||||
);
|
||||
} catch (ApiErrorException $e) {
|
||||
$this->assertEquals(ApiError::validationFailed(), $e->getApiError());
|
||||
|
|
@ -80,8 +80,8 @@ class CrmClientV2StatsTest extends CrmClientTester
|
|||
|
||||
try {
|
||||
Stats::getBrandStats(
|
||||
$start->format('Y-m-d'),
|
||||
$end->format('Y-m-d')
|
||||
$start->isoFormat('YYYY-MM-DD'),
|
||||
$end->isoFormat('YYYY-MM-DD')
|
||||
);
|
||||
} catch (ApiErrorException $e) {
|
||||
$this->assertEquals(ApiError::validationFailed(), $e->getApiError());
|
||||
|
|
@ -106,12 +106,12 @@ class CrmClientV2StatsTest extends CrmClientTester
|
|||
new ModelsQuestion([
|
||||
'id' => $question->id
|
||||
]),
|
||||
$start->format('Y-m-d'),
|
||||
$end->format('Y-m-d')
|
||||
$start->isoFormat('YYYY-MM-DD'),
|
||||
$end->isoFormat('YYYY-MM-DD')
|
||||
);
|
||||
|
||||
do {
|
||||
$startD = $start->format('Y-m-d');
|
||||
$startD = $start->isoFormat('YYYY-MM-DD');
|
||||
$this->assertArrayHasKey($startD, $stats['stats']);
|
||||
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
||||
foreach ($answersIds as $key => $id) {
|
||||
|
|
@ -140,8 +140,8 @@ class CrmClientV2StatsTest extends CrmClientTester
|
|||
new ModelsQuestion([
|
||||
'id' => $question->id
|
||||
]),
|
||||
$start->format('Y-m-d'),
|
||||
$end->format('Y-m-d')
|
||||
$start->isoFormat('YYYY-MM-DD'),
|
||||
$end->isoFormat('YYYY-MM-DD')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -162,8 +162,8 @@ class CrmClientV2StatsTest extends CrmClientTester
|
|||
new ModelsQuestion([
|
||||
'id' => $question->id
|
||||
]),
|
||||
$start->format('Y-m-d'),
|
||||
$end->format('Y-m-d')
|
||||
$start->isoFormat('YYYY-MM-DD'),
|
||||
$end->isoFormat('YYYY-MM-DD')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -184,8 +184,8 @@ class CrmClientV2StatsTest extends CrmClientTester
|
|||
new ModelsQuestion([
|
||||
'id' => $question->id
|
||||
]),
|
||||
$start->format('Y-m-d'),
|
||||
$end->format('Y-m-d')
|
||||
$start->isoFormat('YYYY-MM-DD'),
|
||||
$end->isoFormat('YYYY-MM-DD')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue