]> _ Git - psq.git/commitdiff
reorder ads, revamp agenda + prev/next btns
authorLouis Jeckel <louis.jeckel@outlook.cm>
Mon, 28 Sep 2020 09:20:22 +0000 (11:20 +0200)
committerLouis Jeckel <louis.jeckel@outlook.cm>
Mon, 28 Sep 2020 09:20:22 +0000 (11:20 +0200)
app/Http/Controllers/AdCampaignController.php
app/Http/Controllers/Admin/AdCampaignController.php
app/Http/Controllers/EnPlusController.php
app/Models/WeeklyAgenda.php
database/migrations/2020_09_28_084558_add_position_to_ad_campaigns.php [new file with mode: 0644]
resources/views/actu-labos/index.blade.php
resources/views/en-plus/agenda/show.blade.php
resources/views/en-plus/index.blade.php

index 854c0a13c4c90c260e1beee9496e923ac12eb783..28797e2f9fbb3a090f65068c62b0c352fc7becc3 100644 (file)
@@ -15,13 +15,13 @@ class AdCampaignController extends Controller
     }
 
     /**
+     * @param AdCampaignRepository $repository
      * @return \Illuminate\View\View
-     *
      */
-    public function index()
+    public function index(AdCampaignRepository $repository)
     {
         $campaigns = AdCampaign::query()
-            ->orderByDesc('id')
+            ->orderBy('position')
             ->take(3)
             ->published()
             ->visible()
index 4d80a3ed3ef09425c39113df0dd02dd15226edd7..d76612f5ebe386c997bc4ac6b737cc39123ec635 100644 (file)
@@ -11,8 +11,9 @@ class AdCampaignController extends ModuleController
     protected $permalinkBase = 'campagnes-et-communication';
 
     protected $indexOptions = [
-//        'reorder' => true
+        'reorder' => true
     ];
+
 }
 
 
index 8e95ac1e78ef6214240ca64da8a74bf9687169c9..200496bdf4f1973ea11a5bf77d604ed2ffb4af26 100644 (file)
@@ -13,11 +13,12 @@ class EnPlusController extends Controller
     public function index()
     {
         \View::share('humeur', Humeur::query()->orderByDesc('id')->firstOrFail());
-        $agenda = WeeklyAgenda::query()
+        $agendas = WeeklyAgenda::query()
             ->orderBy('start_date')
             ->where('start_date', '>=', now()->addDay()->startof('week'))
-            ->first();
-        \View::share('agenda', $agenda);
+            ->take(4)
+            ->get();
+        \View::share('agendas', $agendas);
         \View::share('title', "Agenda et Humeur");
 
         return view('en-plus.index');
index 97d532055697d8ee6961a5a85a028fb87839d176..78d5f625619a8fb88d71399413c0fc745188e750 100644 (file)
@@ -12,6 +12,7 @@ use Carbon\Carbon;
  * @package App\Models
  * @property Carbon $start_date
  * @property-read Carbon $end_date
+ * @property int $id
  */
 class WeeklyAgenda extends Model
 {
@@ -43,14 +44,28 @@ class WeeklyAgenda extends Model
         return $this->startDateCarbon()->format('d/m/Y');
     }
 
+    /**
+     * @return string
+     */
     public function getFullTitle()
     {
-        return "Semaine du {$this->startDateCarbon()->format('d/m/Y')} au {$this->endDateCarbon()->format('d/m/Y')}";
+        return "Semaine du ".$this->getDatesString();
+    }
+
+    /**
+     * @return string
+     */
+    public function getDatesString()
+    {
+        return "{$this->startDateCarbon()->format('d/m/Y')} au {$this->endDateCarbon()->format('d/m/Y')}";
     }
 
+    /*
+     *
+     */
     public function getUrlAttribute()
     {
-        return route('agenda.show', ['agenda' => $this->id]);
+        return route('agenda.show', ['agenda' => $this->start_date]);
     }
 
 
@@ -70,6 +85,27 @@ class WeeklyAgenda extends Model
         return $this->startDateCarbon()->addWeek();
     }
 
+    /**
+     * @return WeeklyAgenda|null
+     */
+    public function nextWeek(): ?WeeklyAgenda
+    {
+         return self::query()
+             ->orderBy('start_date')
+             ->where('start_date', '>', $this->start_date)
+             ->first();
+    }
+
+    /**
+     * @return WeeklyAgenda|null
+     */
+    public function previousWeek(): ?WeeklyAgenda
+    {
+         return self::query()
+             ->orderByDesc('start_date')
+             ->where('start_date', '<', $this->start_date)
+             ->first();
+    }
 
     /**
      * @return string|null
diff --git a/database/migrations/2020_09_28_084558_add_position_to_ad_campaigns.php b/database/migrations/2020_09_28_084558_add_position_to_ad_campaigns.php
new file mode 100644 (file)
index 0000000..77639a9
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddPositionToAdCampaigns extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('ad_campaigns', function (Blueprint $table) {
+            //
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('ad_campaigns', function (Blueprint $table) {
+            //
+        });
+    }
+}
index bf2fa58e4104fc12c3a19c3cf8fdec1727b0f827..ef69c86738e5801a79232cf36c314d9e3d0de015 100644 (file)
@@ -4,7 +4,7 @@
 @section('content')
     <div class="container psq-labos">
         <h1>L'actu des labos</h1>
-        <h2 class="text-center">Une séléction de nos articles publiés cette semaine</h2>
+        <h2 class="text-center">Une sélection de nos articles publiés récemment</h2>
 
 
         <div class="mt-5 row">
index a60f1a7984506f4df0da2e2088da463e6bdcbac8..044cde25eb8b382eaca44aec5e45067b08bb45ab 100644 (file)
             @foreach($agenda->imageObjects('events') as $event)
                 <div class="col-sm-4 mb-2">
                     @if(!empty($url =  $event->getMetadata('url')))
-                    <a href="{!! $url!!}" target="_blank">
-                    @endif
+                        <a href="{!! $url!!}" target="_blank">
+                            @endif
 
-                        <img src="{{$imageService::getUrl($event->uuid)}}" alt="" class="w-100">
-                    @if(!empty($url))
-                    </a>
+                            <img src="{{$imageService::getUrl($event->uuid)}}" alt="" class="w-100">
+                            @if(!empty($url))
+                        </a>
                     @endif
 
                 </div>
 
         </div>
 
+        <div class="row">
+            <div class="col-6">
+                @if(null !== $a = $agenda->previousWeek())
+                    <a href="{{$a->url}}" class="btn btn-back">❮ Semaine précédente</a>
+                @endif
+            </div>
+            <div class="col-6">
+                @if(null !== $a = $agenda->nextWeek())
+                    <a href="{{$a->url}}" class="btn btn-back float-right">Semaine suivante ❯</a>
+                @endif
+            </div>
+        </div>
+
+
 
 
     </div>
index 6768b60f1720327ae826337c46b63437459d51ef..3966aa3175c3da09abf7052524a047820f3b52cf 100644 (file)
             </div>
             <div class="col-sm-6">
                 <h1>L’AGENDA DES ACTEURS DU MÉDICAMENT</h1>
-                @if($agenda === null)
+                @if(count($agendas) === 0)
                     <h2>Aucun événement pour cette semaine...</h2>
                 @else
-                    @if($event = $agenda->imageObject('events'))
-                        @if(!empty($url = $event->getMetadata('url')))
-                            <a href="{!! $url !!}" target="_blank">
-                        @endif
-                            <img style="max-width: 350px;" class="w-100 d-block m-auto" src="{{$agenda->image('events')}}" alt="">
-                        @if(!empty($url))
+                    <p class="text-left my-3" style="font-size: x-large">
+                        Les Conférences de presse, les Colloques, les Rendez-Vous et les Dates essentielles des acteurs du Médicament et de leurs Partenaires
+                    </p>
+
+
+                    <h3>Les Rendez-Vous de la Pharma du </h3>
+                    <ul>
+
+                    @foreach($agendas as $agenda)
+                        <li>
+                            <a href="{{$agenda->url}}" class="click-here text-left mt-3">
+                                {{$agenda->getDatesString()}}
                             </a>
-                        @endif
-                    @endif
-    
-                    <a href="{{route('agenda.show', ['agenda' => $agenda->start_date])}}" class="click-here text-left mt-3">Les Conférences de presse, les Colloques, les Rendez-Vous et les Dates essentielles des acteurs du Médicament et de leurs Partenaires</a>
+
+                        </li>
+
+
+                    @endforeach
+                    </ul>
+
                 @endif
             </div>
         </div>