Text::make('Position'),
Text::make('Téléphone', 'phone'),
new Panel('Adresse', $this->addressFields()),
+ new Panel('Réglages', [
+ Select::make('Type')->options([
+ AppUser::TYPE_SUBSCRIBER => 'Abonné',
+ AppUser::TYPE_PROSPECT => 'Prospect',
+ AppUser::TYPE_SPECIAL => 'Autre',
+ AppUser::TYPE_DISCOVER => 'Découverte',
+ ])->hideFromIndex()->required()->withMeta(['value' => $this->type ?? static::$type ?? AppUser::TYPE_SUBSCRIBER]),
+ Boolean::make('Compte activé', 'reg_complete')->hideWhenCreating()->hideWhenUpdating()->readonly(),
+ Boolean::make('Reçoit fichier PDF', 'receives_pdf')->hideFromIndex(),
+
+ ]),
new Panel('Affiliation', [
BelongsTo::make('Organisation', 'organization', Organization::class)->searchable()->nullable(),
]),
- ], $this->extraFields(), [
- Boolean::make('Compte activé', 'reg_complete')->hideWhenCreating(),
- Select::make('Type')->options([
- AppUser::TYPE_SUBSCRIBER => 'Abonné',
- AppUser::TYPE_PROSPECT => 'Prospect',
- AppUser::TYPE_SPECIAL => 'Autre',
- AppUser::TYPE_DISCOVER => 'Découverte',
- ])->hideFromIndex()->required()->withMeta(['value' => $this->type ?? static::$type ?? AppUser::TYPE_SUBSCRIBER]),
+ ], $this->extraFields(), [
Badge::make('Etat', fn() => AppUser::STATUSES[$this->status]['label'])
->map(Arr::pluck(AppUser::STATUSES, 'badge', 'label')),
]);
);
}
+ /**
+ * @return string
+ * Returns download link.
+ */
+ public function getDownloadUrl(): string
+ {
+ return \URL::temporarySignedRoute(
+ 'pdf.download',
+ now()->addDays(3),
+ ['file' => $this->slug]
+ );
+ }
+
/**
* @param User $user
* @return string
*/
public function getMailableUrl(User $user): string
{
+ if($user->receives_pdf) {
+ return $this->getDownloadUrl();
+ }
return ($user->type === User::TYPE_DISCOVER && !$user->self_registered) ?
$this->getSignedUrl($user) :
$this->getUrlWithToken($user);
* @property int $type
* @property bool $unsubscribed
* @property bool $reg_complete
+ * @property bool $receives_pdf
*
* @property string $status
*/
'self_registered' => 'bool',
'early_access' => 'bool',
'unsubscribed' => 'bool',
+ 'receives_pdf' => 'bool',
];
--- /dev/null
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddReceivesPdfColToUsers extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ Schema::table('users', function (Blueprint $table) {
+ $table->boolean('receives_pdf')->default(0);
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('users', function (Blueprint $table) {
+ $table->dropColumn('receives_pdf');
+ });
+ }
+}