namespace App\Http\Controllers\Admin;
use A17\Twill\Http\Controllers\Admin\ModuleController;
-use App\PdfFile;
class PdfFileController extends ModuleController
{
// 'publish' => false,
'delete' => false,
'restore' => false,
-
+ 'edit' => false,
];
protected $indexColumns = [
'title' => 'Titre',
'field' => 'title'
],
- 'viewCount' => [
- 'title' => 'Vues',
- 'field' => 'viewCount'
- ]
+// 'viewCount' => [
+// 'title' => 'Vues',
+// 'field' => 'viewCount'
+// ]
];
- public function edit($id, $submoduleId = null)
- {
- /** @var PdfFile $pdf */
- $pdf = PdfFile::with(['trackedLinks'])
- ->find($id);
-
- \View::share('pdf', $pdf);
- \View::share('batch', $pdf->emailBatch);
-
- \View::share('stats', optional($pdf->emailBatch)->statistics());
-
- return view('admin.pdfFiles.show');
- }
+// public function edit($id, $submoduleId = null)
+// {
+// /** @var PdfFile $pdf */
+// $pdf = PdfFile::with(['trackedLinks'])
+// ->find($id);
+//
+// \View::share('pdf', $pdf);
+// \View::share('batch', $pdf->emailBatch);
+//
+// \View::share('stats', optional($pdf->emailBatch)->statistics());
+//
+// return view('admin.pdfFiles.show');
+// }
}
--- /dev/null
+<?php
+
+namespace App\Models;
+
+use A17\Twill\Models\Behaviors\HasBlocks;
+use A17\Twill\Models\Behaviors\HasSlug;
+use A17\Twill\Models\Behaviors\HasMedias;
+use A17\Twill\Models\Block;
+use A17\Twill\Models\Model;
+use App\PollEntry;
+use Illuminate\Support\Collection;
+use Illuminate\Support\Str;
+
+/**
+ * Class Poll
+ * @package App\Models
+ * @property-read int $entriesCount
+ */
+class Poll extends Model implements HasUrl
+{
+ use HasBlocks, HasSlug, HasMedias;
+
+ protected $fillable = [
+ 'published',
+ 'title',
+ 'description',
+ ];
+
+ public $slugAttributes = [
+ 'title',
+ ];
+
+ public static $pollTypes = [
+ 'poll_text' => 'Question ouverte (texte)',
+ 'poll_check_check' => 'Question fermée (choix multiples)',
+ 'poll_check_radio' => 'Question fermée (choix unique)',
+ ];
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
+ public function entries()
+ {
+ return $this->hasMany(PollEntry::class);
+ }
+
+ /**
+ * @return int
+ */
+ public function getEntriesCountAttribute(): int
+ {
+ return $this->entries()->count();
+ }
+
+
+ /**
+ * @return Collection
+ */
+ public function getQuestions()
+ {
+ $questions = $this->blocks()->whereNull('parent_id')->get();
+
+ return $questions->map(function(Block $q) {
+ $q->options = $q->children;
+ $subtype = $q->input('type');
+ $subtype = $subtype === null ?
+ '' :
+ "_$subtype";
+
+ return [
+ 'type' => $type = $q->type.$subtype,
+ 'type_str' => self::$pollTypes[$type] ?? 'Type inconnu',
+ 'question' => $question = $q->input('question'),
+ 'slug' => Str::slug($question),
+ 'position' => $q->position,
+ 'choices' => $q->children->map(function(Block $choice) {
+ return [
+ 'position' => $choice->position,
+ 'option' => $choice->input('option'),
+ 'slug' => Str::slug($choice->input('option')),
+ ];
+ })
+ ];
+ })->filter(fn($q) => $q['question'] !== null);
+
+ }
+
+ /**
+ * @return string
+ */
+ public function getUrlAttribute(): string
+ {
+ return route('poll.show', ['slug' => $this->slug]) ?? '#';
+ }
+}
@section('content')
- <div class="bootstrap">
- <div class="container mt-4">
- <div class="row">
- <div class="col-6">
- @if($batch)
- <h3>Email envoyé : </h3>
- <iframe class="mb-4" width="100%" height="600px" srcdoc="{{ $batch->render() }}" frameborder="0"></iframe>
- @endif
- @if($pdf)
- <hr>
- <h3>Lettre :</h3>
- <img src="{{$pdf->coverUrl}}" alt="Cover" style="max-width: 400px;" class="d-block m-auto">
- <a href="{{route('admin.preview', ['slug' => $pdf->slug])}}" target="_blank" class="btn btn-primary mt-3">Lire</a>
- @foreach($pdf->headlines ?? [] as $headline)
- <x-headline :headline="$headline" class="mt-3">
- </x-headline>
- @endforeach
- @endif
- </div>
- <div class="col-6">
- <h1>{{$batch->subject ?? $pdf->title}}</h1>
- <p>{{$batch->dateString ?? $pdf->created_at}}</p>
- <div class="row">
- @if($pdf)
- <div class="col-12">
- <h3>Statistiques de lecture</h3>
- </div>
- <div class="col-md-6 mt-2">
- <mg-stats icon="opened" custom-metric="{{$pdf->viewCount}}" custom-label="Lectures authentifiées"></mg-stats>
- </div>
- <div class="col-md-6 mt-2">
- <mg-stats icon="opened" custom-metric="{{$pdf->accessLogs()->count()}}" custom-label="Lectures totales"></mg-stats>
- </div>
- @endif
- @unless($stats === null)
- <div class="col-12">
- <h3 class="mt-3">Statistiques mailing</h3>
- </div>
- <div class="col-md-6 mt-2">
- <mg-stats icon="delivered" current="{{$stats['delivered'] ?? 0}}" total="{{$stats['total'] ?? 0}}" text="reçus"></mg-stats>
- </div>
- <div class="col-md-6 mt-2">
- <mg-stats icon="opened" current="{{$stats['opened'] ?? 0}}" total="{{$stats['total'] ?? 0}}" text="ouverts"></mg-stats>
- </div>
- <div class="col-md-6 mt-2">
- <mg-stats icon="clicked" current="{{$stats['clicked'] ?? 0}}" total="{{$stats['total'] ?? 0}}" text="cliqués"></mg-stats>
- </div>
- <div class="col-md-6 mt-2">
- <mg-stats icon="suppressed" current="{{$stats['suppressed'] ?? 0}}" total="{{$stats['total'] ?? 0}}" text="annulés"></mg-stats>
- </div>
- <div class="col-md-6 mt-2">
- <mg-stats icon="failed" current="{{$stats['failed'] ?? 0}}" total="{{$stats['total'] ?? 0}}" text="erreur"></mg-stats>
- </div>
- @else
- <div class="col-12 mt-3">
- <p>Cette lettre n'a pas été envoyée via la plateforme. Les statistiques d'envoi ne sont pas disponibles</p>
- </div>
- @endif
- </div>
+{{-- <div class="bootstrap">--}}
+{{-- <div class="container mt-4">--}}
+{{-- <div class="row">--}}
+{{-- <div class="col-6">--}}
+{{-- @if($batch)--}}
+{{-- <h3>Email envoyé : </h3>--}}
+{{-- <iframe class="mb-4" width="100%" height="600px" srcdoc="{{ $batch->render() }}" frameborder="0"></iframe>--}}
+{{-- @endif--}}
+{{-- @if($pdf)--}}
+{{-- <hr>--}}
+{{-- <h3>Lettre :</h3>--}}
+{{-- <img src="{{$pdf->coverUrl}}" alt="Cover" style="max-width: 400px;" class="d-block m-auto">--}}
+{{-- <a href="{{route('admin.preview', ['slug' => $pdf->slug])}}" target="_blank" class="btn btn-primary mt-3">Lire</a>--}}
+{{-- @foreach($pdf->headlines ?? [] as $headline)--}}
+{{-- <x-headline :headline="$headline" class="mt-3">--}}
+{{-- </x-headline>--}}
+{{-- @endforeach--}}
+{{-- @endif--}}
+{{-- </div>--}}
+{{-- <div class="col-6">--}}
+{{-- <h1>{{$batch->subject ?? $pdf->title}}</h1>--}}
+{{-- <p>{{$batch->dateString ?? $pdf->created_at}}</p>--}}
+{{-- <div class="row">--}}
+{{-- @if($pdf)--}}
+{{-- <div class="col-12">--}}
+{{-- <h3>Statistiques de lecture</h3>--}}
+{{-- </div>--}}
+{{-- <div class="col-md-6 mt-2">--}}
+{{-- <mg-stats icon="opened" custom-metric="{{$pdf->viewCount}}" custom-label="Lectures authentifiées"></mg-stats>--}}
+{{-- </div>--}}
+{{-- <div class="col-md-6 mt-2">--}}
+{{-- <mg-stats icon="opened" custom-metric="{{$pdf->accessLogs()->count()}}" custom-label="Lectures totales"></mg-stats>--}}
+{{-- </div>--}}
+{{-- @endif--}}
+{{-- @unless($stats === null)--}}
+{{-- <div class="col-12">--}}
+{{-- <h3 class="mt-3">Statistiques mailing</h3>--}}
+{{-- </div>--}}
+{{-- <div class="col-md-6 mt-2">--}}
+{{-- <mg-stats icon="delivered" current="{{$stats['delivered'] ?? 0}}" total="{{$stats['total'] ?? 0}}" text="reçus"></mg-stats>--}}
+{{-- </div>--}}
+{{-- <div class="col-md-6 mt-2">--}}
+{{-- <mg-stats icon="opened" current="{{$stats['opened'] ?? 0}}" total="{{$stats['total'] ?? 0}}" text="ouverts"></mg-stats>--}}
+{{-- </div>--}}
+{{-- <div class="col-md-6 mt-2">--}}
+{{-- <mg-stats icon="clicked" current="{{$stats['clicked'] ?? 0}}" total="{{$stats['total'] ?? 0}}" text="cliqués"></mg-stats>--}}
+{{-- </div>--}}
+{{-- <div class="col-md-6 mt-2">--}}
+{{-- <mg-stats icon="suppressed" current="{{$stats['suppressed'] ?? 0}}" total="{{$stats['total'] ?? 0}}" text="annulés"></mg-stats>--}}
+{{-- </div>--}}
+{{-- <div class="col-md-6 mt-2">--}}
+{{-- <mg-stats icon="failed" current="{{$stats['failed'] ?? 0}}" total="{{$stats['total'] ?? 0}}" text="erreur"></mg-stats>--}}
+{{-- </div>--}}
+{{-- @else--}}
+{{-- <div class="col-12 mt-3">--}}
+{{-- <p>Cette lettre n'a pas été envoyée via la plateforme. Les statistiques d'envoi ne sont pas disponibles</p>--}}
+{{-- </div>--}}
+{{-- @endif--}}
+{{-- </div>--}}
- @if($pdf)
- <div class="mt-5 box p-2">
- <h2>Links</h2>
- <table class="table table-hover">
- <thead>
- <tr>
- <th>Titre</th>
- <th>Clics</th>
- </tr>
- </thead>
- <tbody>
- @foreach($pdf->trackedLinks as $link)
- <tr>
- <td><a href="{!! $link->target !!}" target="_blank">{!! $link->title !!}</a></td>
- <td>{{$link->clicks}}</td>
- </tr>
- @endforeach
- </tbody>
- </table>
- </div>
- @endif
+{{-- @if($pdf)--}}
+{{-- <div class="mt-5 box p-2">--}}
+{{-- <h2>Links</h2>--}}
+{{-- <table class="table table-hover">--}}
+{{-- <thead>--}}
+{{-- <tr>--}}
+{{-- <th>Titre</th>--}}
+{{-- <th>Clics</th>--}}
+{{-- </tr>--}}
+{{-- </thead>--}}
+{{-- <tbody>--}}
+{{-- @foreach($pdf->trackedLinks as $link)--}}
+{{-- <tr>--}}
+{{-- <td><a href="{!! $link->target !!}" target="_blank">{!! $link->title !!}</a></td>--}}
+{{-- <td>{{$link->clicks}}</td>--}}
+{{-- </tr>--}}
+{{-- @endforeach--}}
+{{-- </tbody>--}}
+{{-- </table>--}}
+{{-- </div>--}}
+{{-- @endif--}}
- </div>
- </div>
- </div>
+{{-- </div>--}}
+{{-- </div>--}}
+{{-- </div>--}}
- </div>
+{{-- </div>--}}
@endsection