%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/news/vendor/czim/laravel-repository/src/Traits/
Upload File :
Create Path :
Current File : /var/www/html/news/vendor/czim/laravel-repository/src/Traits/FindsModelsByTranslationTrait.php

<?php
namespace Czim\Repository\Traits;

use Czim\Repository\Criteria\Translatable\WhereHasTranslation;

trait FindsModelsByTranslationTrait
{
    /**
     * Finds a/first model by a given translated property
     *
     * @param string $attribute must be translated property!
     * @param string $value
     * @param string $locale
     * @param bool   $exact     = or LIKE match
     * @return \Illuminate\Database\Eloquent\Model|null
     */
    public function findByTranslation($attribute, $value, $locale = null, $exact = true)
    {
        $this->pushCriteriaOnce( new WhereHasTranslation($attribute, $value, $locale, $exact) );

        return $this->first();
    }

    /**
     * Finds models by a given translated property
     *
     * @param string $attribute must be translated property!
     * @param string $value
     * @param string $locale
     * @param bool   $exact     = or LIKE match
     * @return \Illuminate\Support\Collection
     */
    public function findAllByTranslation($attribute, $value, $locale = null, $exact = true)
    {
        $this->pushCriteriaOnce( new WhereHasTranslation($attribute, $value, $locale, $exact) );

        return $this->all();
    }
}

Zerion Mini Shell 1.0