--- /dev/null
+<?php
+
+namespace App\Nova\Actions;
+
+use App\User;
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Support\Collection;
+use Laravel\Nova\Actions\Action;
+use Laravel\Nova\Fields\ActionFields;
+
+class MakeProspect extends Action
+{
+ use InteractsWithQueue, Queueable;
+
+ public $showOnTableRow = true;
+ public $name = "Passer en prospect";
+ public $confirmText = "Voulez vous vraiment passer ces utilisateurs dans le fichier prospect ?";
+ public $confirmButtonText = "Oui";
+
+ /**
+ * Perform the action on the given models.
+ *
+ * @param \Laravel\Nova\Fields\ActionFields $fields
+ * @param \Illuminate\Support\Collection $models
+ * @return mixed
+ */
+ public function handle(ActionFields $fields, Collection $models)
+ {
+ $models->map->update(['type' => User::TYPE_PROSPECT]);
+ }
+
+ /**
+ * Get the fields available on the action.
+ *
+ * @return array
+ */
+ public function fields()
+ {
+ return [];
+ }
+}
{
use InteractsWithQueue, Queueable;
- private $setActive;
-
public $showOnTableRow = true;
// public $withoutConfirmation = true;
- public function __construct($setActive)
- {
- $this->setActive = $setActive;
- }
public function name()
{
- return $this->setActive ?
- "Activer abonnement" :
- "Désabonner";
+ return "Activer abonnement";
}
/**
*/
public function handle(ActionFields $fields, Collection $models)
{
- $models->map->update(['subscription_active' => $this->setActive]);
-
- if($this->setActive) {
$models->map(function (Organization $orga) use($fields){
/** @see User::prepareForSubscription() */
$orga->members->map->sendSubscribedNotification();
}
});
- }
-
-
- $message = $this->setActive ?
- "Abonnement activé avec succès" :
- "Abonnement désactivé avec succès";
- return Action::message($message);
+ return Action::message("Abonnement activé avec succès");
}
*/
public function fields()
{
- return $this->setActive ? [
+ return [
Boolean::make("Ne pas notifier", 'dont_notify')
- ] : [];
+ ];
}
}
public function __construct()
{
- $this->confirmText = sprintf("Etes vous sûr de vouloir activer une période de découverte de %d jours ?", User::TRIAL_DURATION_DAYS);
+ $this->confirmText = sprintf("Etes vous sûr de vouloir activer une période de découverte ?");
}
$users->map(function(User $user) use($fields) {
$user->type = User::TYPE_SUBSCRIBER;
- $user->organization()->associate(\App\Organization::query()->findOrFail($fields->org_id));
$user->save();
if(! $fields->dont_notify) {
$user->sendSubscribedNotification();
public function fields()
{
return [
- Select::make('Organisation', 'org_id')->options(
- \App\Organization::query()
- ->orderBy('name')
- ->where('subscription_active', 1)
- ->get()
- ->pluck('name', 'id')
-
- )->searchable(),
Boolean::make("Ne pas notifier", 'dont_notify')
];
}
namespace App\Nova;
+use App\Nova\Actions\MakeProspect;
use App\Nova\Actions\SubscribeUser;
use Carbon\Carbon;
use Laravel\Nova\Fields\DateTime;
{
return array_merge(parent::actions($request), [
new SubscribeUser,
+ new MakeProspect,
]);
}
Text::make('Nom', 'name'),
HasMany::make('Membres', 'members', User::class),
BelongsTo::make('Type', 'type', OrganizationType::class),
- Boolean::make('Abonnement actif', 'subscription_active')
];
}
public function actions(Request $request)
{
return array_merge([
- new SetSubscriptionStatus(true),
+ new SetSubscriptionStatus,
new SetOrganizationMembersType(\App\User::TYPE_PROSPECT),
new SendNotification,
new SetOrganizationMembersType(\App\User::TYPE_DISCOVER),
- new SetSubscriptionStatus(false),
], SendCustomNotification::getActions());
}
}
namespace App\Nova;
+use App\Nova\Actions\MakeProspect;
use App\Nova\Actions\PdfAttachmentSetting;
use App\Nova\Filters\AccountStates;
use Illuminate\Http\Request;
public function actions(Request $request)
{
return array_merge([
+ new MakeProspect,
new PdfAttachmentSetting(true),
new PdfAttachmentSetting(false)
],parent::actions($request));
use Searchable;
protected $casts = [
- 'subscription_active' => 'boolean'
];
protected $guarded = [];
];
}
- /**
- * @return boolean
- */
- public function isSubscribed(): bool
- {
- return $this->subscription_active;
- }
- /**
- * @param Builder $builder
- * @return Builder
- */
- public function scopeSubscribed(Builder $builder): Builder
- {
- return $builder->where('subscription_active', 1);
- }
/**
* @return HasMany
* @property-read $name
* @property Organization $organization
* @property string $position
- * @property bool $orgIsSubscribed (is user has org subscribed)
* @property Carbon $trial_ends_at (is user is on trial)
* @property Carbon $discover_ends_at
* @property bool self_registered (if user used /register)
'badge' => 'danger',
'label' => 'Aucun abonnement'
],
- 'org_subscribed' => [
- 'badge' => 'success',
- 'label' => 'Abonnement actif (orga)'
- ],
'ind_subscribed' => [
'badge' => 'success',
'label' => 'Abonnement actif (indep)'
return $this->hasValidSubscription() || $this->isOnDiscoverUser() || $this->onTrial();
}
- /**
- * @return bool
- * Checks if affiliated organization has valid subscription
- */
- public function orgIsSubscribed(): bool
- {
- return ($o = $this->organization) === null ?
- false:
- $o->isSubscribed();
- }
/**
* @return bool
* ATTRIBUTES
*/
- /**
- * @return bool
- */
- public function getOrgIsSubscribedAttribute(): bool
- {
- return $this->orgIsSubscribed();
- }
+
/**
* @return bool
'aws_s3_url' => 'https://prescription-sante.s3.eu-west-3.amazonaws.com',
- 'version' => '0.9.1',
+ 'version' => '0.10.0 beta 1',
'emails' => [
'subscriptions' => 'abonnement@prescription-quotidien.com',