]> _ Git - psq.git/commitdiff
les labos
authorLouis Jeckel <louis.jeckel@outlook.cm>
Thu, 13 Aug 2020 10:35:45 +0000 (12:35 +0200)
committerLouis Jeckel <louis.jeckel@outlook.cm>
Thu, 13 Aug 2020 10:35:45 +0000 (12:35 +0200)
16 files changed:
app/Http/Controllers/ActuLabosController.php
app/Http/Controllers/Admin/PillBoxSpaceController.php
app/Models/LaboArticle.php
app/Models/PillBoxSpace.php
app/Repositories/PillBoxSpaceRepository.php
database/migrations/2020_08_13_084135_remove_preview_from_labo_articles.php [new file with mode: 0644]
public/css/app.css
resources/sass/_colors.scss
resources/sass/app.scss
resources/views/actu-labos/index.blade.php
resources/views/actu-labos/show.blade.php
resources/views/admin/laboArticles/form.blade.php
resources/views/components/back.blade.php [new file with mode: 0644]
resources/views/components/simple-preview.blade.php [new file with mode: 0644]
resources/views/podcasts/index.blade.php
routes/web.php

index 715c1d12a9d7c475174541c933f6a3820346318e..be4dd5e40b904456b4da56478a3ef5b0e5b51cab 100644 (file)
@@ -3,13 +3,27 @@
 namespace App\Http\Controllers;
 
 use App\Models\LaboArticle;
+use App\Repositories\LaboArticleRepository;
 use Illuminate\Http\Request;
 
 class ActuLabosController extends Controller
 {
     public function index()
     {
-        \View::share('actus', LaboArticle::query()->orderBy('position')->published()->take(4)->get());
+        \View::share('actus', LaboArticle::query()->orderBy('position')->published()->visible()->take(4)->get());
         return view('actu-labos.index');
     }
+
+
+    public function show($slug, LaboArticleRepository $repository)
+    {
+
+        $actu = $repository->forSlug($slug);
+
+
+        \View::share('actu', $actu);
+        return view('actu-labos.show');
+    }
 }
+
+
index 334f9bb07721977b523bfeb186d7aea6c1725791..7f5dc68ccb27f3877eb311825f25dbff170d3209 100644 (file)
@@ -7,4 +7,23 @@ use A17\Twill\Http\Controllers\Admin\ModuleController;
 class PillBoxSpaceController extends ModuleController
 {
     protected $moduleName = 'pillBoxSpaces';
+
+    protected $indexOptions = [
+        'publish' => false,
+        'bulkPublish' => false,
+    ];
+
+    protected $indexColumns = [
+        'title' => [
+            'title' => 'Emplacement',
+            'field' => 'title',
+            'sort' => true,
+        ],
+        'box_title' => [
+            'title' => "Titre de l'encadré",
+            'field' => 'box_title',
+
+        ]
+
+    ];
 }
index 4a7edd17ed1ad77078a0ce0627e20b5683eea41e..210aa7626c18dae454518351d4efbea1d58fb479 100644 (file)
@@ -8,6 +8,13 @@ use A17\Twill\Models\Behaviors\HasMedias;
 use A17\Twill\Models\Behaviors\Sortable;
 use A17\Twill\Models\Model;
 
+/**
+ * Class LaboArticle
+ * @package App\Models
+ * @property string $content
+ * @property string $link
+ * @property string $preview
+ */
 class LaboArticle extends Model implements Sortable
 {
     use HasSlug, HasMedias, HasPosition;
@@ -17,7 +24,6 @@ class LaboArticle extends Model implements Sortable
         'publish_end_date',
         'title',
         'chapo',
-        'preview',
         'content',
         'published',
         'position',
@@ -37,4 +43,24 @@ class LaboArticle extends Model implements Sortable
             ],
         ],
     ];
+
+
+    public function getPreviewAttribute(): string
+    {
+        $line = strip_tags($this->content);
+
+        if (preg_match('/^.{1,200}\b/s', $line, $match)) {
+            $line = trim($match[0]) . "…";
+        }
+
+        return $line;
+    }
+
+    /**
+     * @return string
+     */
+    public function getLinkAttribute(): string
+    {
+        return route('actus-labos.show', ['slug' => $this->slug]);
+    }
 }
index 5de6418aa50c6266b3716e173eb8116db61faae4..60b8bb9fcd31f4d7ba89b83cbdb96a7142503acd 100644 (file)
@@ -10,7 +10,7 @@ class PillBoxSpace extends Model
     use HasSlug;
 
     protected $fillable = [
-        'published',
+//        'published',
         'title',
         'box_content',
         'box_title',
@@ -21,4 +21,5 @@ class PillBoxSpace extends Model
         'title',
     ];
 
+
 }
index a50d88e10ba25502dc2743723da2d9d822110f8a..3723da124a8786e8176edc3550067c8bd9d3389f 100644 (file)
@@ -14,4 +14,11 @@ class PillBoxSpaceRepository extends ModuleRepository
     {
         $this->model = $model;
     }
+
+    public function afterSave($object, $fields)
+    {
+        parent::afterSave($object, $fields);
+        $object->published = true;
+        $object->save();
+    }
 }
diff --git a/database/migrations/2020_08_13_084135_remove_preview_from_labo_articles.php b/database/migrations/2020_08_13_084135_remove_preview_from_labo_articles.php
new file mode 100644 (file)
index 0000000..7babed7
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class RemovePreviewFromLaboArticles extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('labo_articles', function (Blueprint $table) {
+            $table->dropColumn('preview');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('labo_articles', function (Blueprint $table) {
+            $table->text('preview')->nullable();
+        });
+    }
+}
index 8baa9a6aad953b8bd3d84a5de37d6769a14ec7e8..3322380693cf162c445cad93cfd9d5d0326a5247 100644 (file)
@@ -11050,7 +11050,8 @@ mark.mark {
   color: #074e9c;
 }
 
-.highlight-blue {
+.highlight-blue,
+.btn-back {
   color: white;
   background-color: #074e9c;
 }
@@ -11173,6 +11174,12 @@ h1 {
   border: 1px solid #d04d4a;
 }
 
+.psq-actu .box,
+.psq-actu div.pill-box div,
+div.pill-box .psq-actu div {
+  border-radius: 5px;
+}
+
 .psq-com-campaign h1 {
   color: white;
   background-color: #AD5ED3;
@@ -11182,6 +11189,12 @@ h1 {
   border: 1px solid #AD5ED3;
 }
 
+.psq-com-campaign .box,
+.psq-com-campaign div.pill-box div,
+div.pill-box .psq-com-campaign div {
+  border-radius: 5px;
+}
+
 .psq-plus h1 {
   color: white;
   background-color: #41BD53;
@@ -11191,6 +11204,12 @@ h1 {
   border: 1px solid #41BD53;
 }
 
+.psq-plus .box,
+.psq-plus div.pill-box div,
+div.pill-box .psq-plus div {
+  border-radius: 5px;
+}
+
 .psq-mag h1 {
   color: white;
   background-color: #ce317c;
@@ -11200,6 +11219,12 @@ h1 {
   border: 1px solid #ce317c;
 }
 
+.psq-mag .box,
+.psq-mag div.pill-box div,
+div.pill-box .psq-mag div {
+  border-radius: 5px;
+}
+
 .psq-podcasts h1 {
   color: white;
   background-color: #288ed7;
@@ -11209,6 +11234,12 @@ h1 {
   border: 1px solid #288ed7;
 }
 
+.psq-podcasts .box,
+.psq-podcasts div.pill-box div,
+div.pill-box .psq-podcasts div {
+  border-radius: 5px;
+}
+
 .psq-labos h1 {
   color: white;
   background-color: #546983;
@@ -11218,6 +11249,12 @@ h1 {
   border: 1px solid #546983;
 }
 
+.psq-labos .box,
+.psq-labos div.pill-box div,
+div.pill-box .psq-labos div {
+  border-radius: 5px;
+}
+
 .psq-not-registered h1 {
   color: white;
   background-color: #e79817;
@@ -11227,6 +11264,12 @@ h1 {
   border: 1px solid #e79817;
 }
 
+.psq-not-registered .box,
+.psq-not-registered div.pill-box div,
+div.pill-box .psq-not-registered div {
+  border-radius: 5px;
+}
+
 .psq-login-logout h1 {
   color: white;
   background-color: #0c2c50;
@@ -11236,6 +11279,12 @@ h1 {
   border: 1px solid #0c2c50;
 }
 
+.psq-login-logout .box,
+.psq-login-logout div.pill-box div,
+div.pill-box .psq-login-logout div {
+  border-radius: 5px;
+}
+
 nav {
   margin-bottom: 0.5rem;
   display: flex;
@@ -11491,6 +11540,36 @@ div.pill-box div > a.bottom-right {
   font-size: small;
 }
 
+.chapo {
+  font-style: italic;
+  font-size: large;
+}
+
+.simple-preview .chapo {
+  font-size: small;
+}
+
+.btn-back {
+  text-transform: uppercase;
+  font-weight: bold;
+  margin-bottom: 1rem;
+  color: white !important;
+}
+
+article > .content {
+  max-width: 800px;
+  font-size: larger;
+  margin: auto;
+  text-align: justify;
+}
+
+article img.top-img {
+  display: block;
+  margin: auto;
+  max-width: 100%;
+  max-height: 350px;
+}
+
 .error-403 p {
   font-size: x-large;
 }
index 8937831d989174ad607c2f807475f61baec764c3..50fd2796670b3f50863922f22ca4752c43275338 100644 (file)
@@ -68,5 +68,10 @@ $psq_pages: (
         .pill-box > div {
             border: 1px solid $color;
         }
+
+        .box {
+            //border: 1px solid $color;
+            border-radius: 5px;
+        }
     }
 }
index 8773bdbac06541d71709936b9168943704dbf94c..df5d0692c85a66d9ca54cce71b5c8f3d304e5dfe 100644 (file)
@@ -80,6 +80,42 @@ a {
 }
 
 
+.chapo {
+    font-style: italic;
+    font-size: large;
+}
+
+.simple-preview{
+    .chapo {
+        font-size: small;
+    }
+}
+
+
+.btn-back {
+    @extend .highlight-blue;
+    text-transform: uppercase;
+    font-weight: bold;
+    margin-bottom: 1rem;
+    color: white !important;
+
+}
+
+article {
+    > .content {
+        max-width: 800px;
+        font-size: larger;
+        margin: auto;
+        text-align: justify;
+    }
+
+    img.top-img {
+        display: block;
+        margin: auto;
+        max-width: 100%;
+        max-height: 350px;
+    }
+}
 .error-403 {
     p {
         font-size: x-large;
index 84977a9b49c4a6160b7d02376b0ed3a78581f134..664c91613fd533b70a2d5474373df434431214cc 100644 (file)
@@ -1,9 +1,36 @@
 @extends('layouts.app')
-
+@php
+@endphp
 @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>
+
+
+        <div class="mt-5 row">
+            <div class="col-sm-6 mb-3">
+                @component('components.simple-preview', ['actu' => $actus->shift()])
+                @endcomponent
+            </div>
+            <div class="col-sm-6 mb-3">
+                @component('components.simple-preview', ['actu' => $actus->shift()])
+                @endcomponent
+            </div>
+            <div class="col-sm-6 mb-3">
+                <x-pill-box class="mb-3" slug="actu-labos-1"></x-pill-box>
+                @component('components.simple-preview', ['actu' => $actus->shift()])
+                @endcomponent
+            </div>
+            <div class="col-sm-6 mb-3">
+                @component('components.simple-preview', ['actu' => $actus->shift()])
+                @endcomponent
+                <x-pill-box class="mb-3" slug="actu-labos-3"></x-pill-box>
+            </div>
+
+
+
+        </div>
 
-@foreach($actus as $actu)
-    {{$actu->title}}
-@endforeach
+    </div>
 
 @endsection
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..14790997b4f3a2b98ebbedd51a0eb527b722b920 100644 (file)
@@ -0,0 +1,19 @@
+@extends('layouts.app')
+
+@section('content')
+    <div class="container psq-labos">
+        <x-back></x-back>
+        <h1>{{$actu->title}}</h1>
+
+        <article>
+            <img src="{{$actu->image('image')}}" class="top-img" alt="">
+            <p class="chapo">{{$actu->chapo}}</p>
+            <div class="content">
+                {!! $actu->content !!}
+            </div>
+        </article>
+
+
+
+    </div>
+@endsection
index 5720aab595c7c04dce20d8f3cef5bea922a3220c..bf564b9cd53a54b8e274c5f20934bc1316656168 100644 (file)
@@ -4,18 +4,11 @@
     @formField('input', [
         'name' => 'chapo',
         'label' => 'Chapô',
-        'maxlength' => 200,
-        'required' => true,
-
-    ])
-    @formField('input', [
-        'name' => 'preview',
-        'label' => 'Extrait',
         'maxlength' => 250,
-        'type' => 'textarea',
         'required' => true,
 
     ])
+
     @formField('wysiwyg', [
         'label' => 'Article complet',
         'name' => 'content',
diff --git a/resources/views/components/back.blade.php b/resources/views/components/back.blade.php
new file mode 100644 (file)
index 0000000..aaa80e6
--- /dev/null
@@ -0,0 +1 @@
+<a href="{{url()->previous()}}" class="btn btn-back">❮ Retour</a>
diff --git a/resources/views/components/simple-preview.blade.php b/resources/views/components/simple-preview.blade.php
new file mode 100644 (file)
index 0000000..f51c839
--- /dev/null
@@ -0,0 +1,20 @@
+
+@if($actu)
+    <div class="box p-2">
+        <div class="row simple-preview">
+
+            <div class="col-4">
+                <img src="{{$actu->image('image')}}" alt="" class="w-100">
+            </div>
+            <div class="col-8">
+                <a href="{{$actu->link}}">
+                    <h2>{{$actu->title}}</h2>
+                </a>
+                <p class="chapo ">{{$actu->chapo}}</p>
+                {{ $actu->preview }}
+                <a href="{{$actu->link}}" class="click-here">Lire la suite</a>
+
+            </div>
+        </div>
+    </div>
+@endif
index 71cccacff4ef606ad236aee7a81371486e03dc20..6233abeb2adf3dee329db49171d927d36a96496e 100644 (file)
@@ -18,7 +18,7 @@
 
 {{--        Description + weekly sponsor --}}
         <div class="col-sm-5 mb-3 px-2">
-            <div class="bg-white p-3">
+            <div class="box p-3">
                 <div class="text-justify mb-2">
                     {!! $podcast->description !!}
                     <hr>
@@ -64,7 +64,7 @@
             <h2 class="text-center">Nos rubriques du mois</h2>
         </div>
 
-        <div class="col-sm-5 px-4">
+        <div class="col-sm-6 px-4">
             <div class="row box mb-3 py-3">
                 <div class="col-12">
                     <h3>Le coup de c&oelig;ur</h3>
@@ -80,6 +80,8 @@
 
                 </div>
             </div>
+        </div>
+        <div class="col-sm-6 px-4">
             <div class="row box mb-4 py-3">
                 <div class="col-12">
                     <h3>Le coup de com</h3>
                 </div>
             </div>
         </div>
-        <div class="col-sm-2 mb-3">
-            <x-pill-box title="Lorem ipsum" color="cyan">
-                Haec dum oriens diu perferret, caeli reserato tepore Constantius consulatu suo septies et Caesaris ter egressus Arelate Valentiam petit, in
-            </x-pill-box>
 
-        </div>
-        <div class="col-sm-5">
+
+
+        <div class="col-sm-6 px-4">
             <div class="row box py-3">
                 <div class="col-12">
                     <h3>Le journal de la com santé</h3>
                 </div>
             </div>
         </div>
+                <div class="col-sm-6 mb-3">
+            <x-pill-box title="Lorem ipsum" color="cyan">
+                Haec dum oriens diu perferret, caeli reserato tepore Constantius consulatu suo septies et Caesaris ter egressus Arelate Valentiam petit, in
+            </x-pill-box>
+
+        </div>
+    </div>
 
 
     </div>
index c2b390237e4f0243493311900b41bf57fe4bbfc1..cc9c3eb356e20babc39958099f20f95e4552b6ef 100644 (file)
@@ -60,7 +60,10 @@ Route::domain(env('CLIENT_DOMAIN_NAME'))->group(function() {
 
     Route::get('pas-encore-inscrit', 'Auth\NotRegisteredYet@index')->name('not-registered');
 
-    Route::get('actus-labos', 'ActuLabosController@index');
+    Route::prefix('actus-labos')->group(function() {
+        Route::get('', 'ActuLabosController@index')->name('actus-labos.index');
+        Route::get('{slug}', 'ActuLabosController@show')->name('actus-labos.show');
+    });
 
     /** Metadata */
     Route::prefix('/files/{file:slug}')->group(function () {