php stan fixes
This commit is contained in:
parent
5d7de5e68a
commit
2ca0e9a315
6 changed files with 19 additions and 13 deletions
|
|
@ -434,7 +434,6 @@ class News extends Model implements TranslatableModel, LocalizedUrlRoutable
|
|||
* Get all published news by category.
|
||||
*
|
||||
* @param string $category
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Collection<int, \App\Models\News>
|
||||
*/
|
||||
public static function getPublishedNewsByCategoryInCurrentLocale(string $category)
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ trait HasCache
|
|||
static::deleted(function () {
|
||||
self::resetCache();
|
||||
});
|
||||
/** @phpstan-ignore-next-line */
|
||||
if (method_exists(static::class, 'initializeSoftDeletes')) {
|
||||
static::restored(function () {
|
||||
self::resetCache();
|
||||
|
|
|
|||
|
|
@ -42,9 +42,11 @@ trait HasUwilImages
|
|||
*/
|
||||
protected static function bootHasUwilImages(): void
|
||||
{
|
||||
/** @phpstan-ignore-next-line */
|
||||
$hadSoftDelete = method_exists(static::class, 'initializeSoftDeletes');
|
||||
|
||||
if ($hadSoftDelete) {
|
||||
/** @phpstan-ignore-next-line */
|
||||
static::forceDeleted(function (self $model) {
|
||||
self::initLoop($model, self::FORCE_DELETE_ACTION);
|
||||
});
|
||||
|
|
@ -134,9 +136,8 @@ trait HasUwilImages
|
|||
continue;
|
||||
} //end if
|
||||
|
||||
// PAS TESTE.
|
||||
// TODO pas testé
|
||||
if (is_array($originalValue) && is_array($currentValue)) {
|
||||
dd('juste array');
|
||||
static::traverseAndManage(
|
||||
$model,
|
||||
$originalValue,
|
||||
|
|
@ -168,7 +169,7 @@ trait HasUwilImages
|
|||
$forceDeleteImage = $eventType === self::FORCE_DELETE_ACTION;
|
||||
$imagesFields = self::getImageFields($model);
|
||||
$wysiwygFields = self::getWysiwygFields($model);
|
||||
$isTranslatable = method_exists($model, 'getTranslations') ?? false;
|
||||
$isTranslatable = method_exists($model, 'getTranslations');
|
||||
$locale = config('app.locale');
|
||||
$availableLocales = array_keys(config('laravellocalization.supportedLocales', ['fr' => "Frenchouz"]));
|
||||
|
||||
|
|
@ -230,7 +231,6 @@ trait HasUwilImages
|
|||
$path = $isList ? "$fieldPath.$key" : (is_int($key) ? $fieldPath : "$fieldPath.$key");
|
||||
// TODO cette récursivité n'a pas encore été testé.
|
||||
if (is_array($oldValue) || is_array($newValue)) {
|
||||
dd('pas testé');
|
||||
static::traverseAndManage(
|
||||
$model,
|
||||
(array) $oldValue,
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ trait HasInertiaPicture
|
|||
*/
|
||||
protected function mergeInertiaPicture(): void
|
||||
{
|
||||
if (empty($this->convertedFiles) || !is_array($this->convertedFiles)) {
|
||||
if (empty($this->convertedFiles)) {
|
||||
return;
|
||||
}
|
||||
$original = $this->all();
|
||||
|
|
@ -47,7 +47,7 @@ trait HasInertiaPicture
|
|||
* Set picture rules (UploadedFile or string path).
|
||||
*
|
||||
* @param string $rules
|
||||
* @return array
|
||||
* @return array<mixed>
|
||||
*/
|
||||
protected function pictureRules(string $rules): array
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use Illuminate\View\Component;
|
|||
|
||||
class NewsNextEventComponent extends Component
|
||||
{
|
||||
/** @var array<\App\Models\News> $nextEvents List of published news. */
|
||||
/** @var \Illuminate\Support\Collection<int, \App\Models\News> $nextEvents List of published news. */
|
||||
public $nextEvents;
|
||||
|
||||
/**
|
||||
|
|
@ -17,20 +17,26 @@ class NewsNextEventComponent extends Component
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
/** @var \App\Models\NewsCategory|null $newsCategory */
|
||||
$newsCategory = NewsCategory::getModelsCached()
|
||||
->filter(fn($category) => $category->getTranslation('slug', 'fr') === "actualites")
|
||||
->first();
|
||||
|
||||
/** @var \App\Models\NewsTag|null $eventTag */
|
||||
$eventTag = NewsTag::getTagsByCategoryInCurrentLocale($newsCategory->slug)
|
||||
->filter(fn($tag) => $tag->getTranslation('slug', 'fr') === "evenement")
|
||||
->filter(
|
||||
fn(\Illuminate\Database\Eloquent\Model $tag) =>
|
||||
$tag instanceof \App\Models\NewsTag && $tag->getTranslation('slug', 'fr') === "evenement"
|
||||
)
|
||||
->first();
|
||||
|
||||
$eventTagId = $eventTag ? $eventTag->id : null;
|
||||
|
||||
/** @var \Illuminate\Support\Collection<int, \App\Models\News> $nextEvents */
|
||||
$this->nextEvents = News::getPublishedNewsByCategoryInCurrentLocale($newsCategory->slug)
|
||||
->filter(function ($news) use ($eventTagId) {
|
||||
return $news->tags->contains(
|
||||
fn ($tag) => $eventTagId === $tag->id
|
||||
fn($tag) => $tag instanceof \App\Models\NewsTag && $eventTagId === $tag->id
|
||||
);
|
||||
})
|
||||
->sortByDesc('published_at')
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@ class OurImplantations extends Component
|
|||
/** @var string $id Identification of the section. */
|
||||
public string $id;
|
||||
|
||||
/** @var $implantations Content section. */
|
||||
/** @var array Content section. */
|
||||
public $implantations;
|
||||
|
||||
/** @var array<\App\Models\Company> $companyModels List of published companies. */
|
||||
/** @var \Illuminate\Database\Eloquent\Collection $companyModels List of published companies. */
|
||||
public $companyModels;
|
||||
|
||||
/** @var array<\App\Models\CompanyActivity> $companyActivityModels List of published company activities. */
|
||||
/** @var \Illuminate\Database\Eloquent\Collection $companyActivityModels List of published company activities. */
|
||||
public $companyActivityModels;
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue