--- /dev/null
+<?php
+
+
+namespace App\Helpers;
+
+
+use Html2Text\Html2Text;
+
+class Helpers
+{
+
+ /**
+ * @param $string
+ * @param $size
+ * @return string
+ * Trims HTML to specified size
+ */
+ public static function htmlTrimMaker($string, $size): string
+ {
+ $line = (new Html2Text($string))->getText();
+
+ if (preg_match("/^.{1,$size}\b/s", $line, $match)) {
+ $line = trim($match[0]) . "…";
+ }
+
+ return $line;
+ }
+
+}
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
+/**
+ * Class SimpleTemplateEngine
+ * @package App\Helpers
+ * @deprecated
+ */
class SimpleTemplateEngine
{
public static function renderWithModel($template, $model)
use A17\Twill\Models\Behaviors\HasMedias;
use A17\Twill\Models\Behaviors\Sortable;
use A17\Twill\Models\Model;
+use App\Helpers\Helpers;
use App\IsStripeUnlockable;
use App\StripePaymentContract;
use Laravel\Scout\Searchable;
public function getPreviewAttribute(): string
{
- $line = (new \Html2Text\Html2Text($this->content))->getText();
-
- if (preg_match('/^.{1,200}\b/s', $line, $match)) {
- $line = trim($match[0]) . "…";
- }
-
- return $line;
+ return Helpers::htmlTrimMaker($this->content, 200);
}
/**
use A17\Twill\Models\Behaviors\HasPosition;
use A17\Twill\Models\Behaviors\Sortable;
use A17\Twill\Models\Model;
+use App\Helpers\Helpers;
use App\IsStripeUnlockable;
use App\StripePaymentContract;
* @package App\Models
* @property string $content
* @property string $title
- * @property string $chapo
+ * @property string $chapo depreciated
* @property int $count
*/
class SocialArticle extends Model implements PillBoxContract, HasUrl, StripePaymentContract
{
return route('social-article.show', ['slug' => $this->slug]);
}
+
+ /**
+ * @return string
+ */
+ protected function getMetaDescription(): string
+ {
+ return Helpers::htmlTrimMaker($this->content, 200);
+ }
}
'max' => 1,
])
- @formField('wysiwyg', [
- 'name' => 'chapo',
- 'label' => 'Chapô',
- ])
+{{-- @formField('wysiwyg', [--}}
+{{-- 'name' => 'chapo',--}}
+{{-- 'label' => 'Chapô',--}}
+{{-- ])--}}
@formField('radios', [
'name' => 'subscriber_only',
'label' => 'Article réservé aux abonnés',
<article class="col-sm-8">
<x-unlocked-article-alerts :article="$article"></x-unlocked-article-alerts>
- <h2>{{$article->title}}</h2>
- <div class="chapo">{!! $article->chapo !!}</div>
+{{-- <h2>{{$article->title}}</h2>--}}
+{{-- <div class="chapo">{!! $article->chapo !!}</div>--}}
<div class="content ck-content mt-5">
<x-subscriber-only-content :article="$article"></x-subscriber-only-content>