Exemplo n.º 1
0
 /**
  * Retrieve the meta data for this model
  *
  * @param Variant $variant
  * @return \Illuminate\Database\Eloquent\Relations\MorphOne
  */
 public function meta(Variant $variant = null)
 {
     if (!$variant) {
         return $this->morphOne('Coreplex\\Meta\\Eloquent\\Meta', 'metable');
     }
     return $this->morphOne('Coreplex\\Meta\\Eloquent\\Meta', 'metable')->where('variant_id', $variant->getKey())->where('variant_type', $variant->getType());
 }
Exemplo n.º 2
0
 /**
  * Find a meta group by it's identifier
  *
  * @param  mixed  $identifier
  * @param Variant $variant
  * @return \Coreplex\Meta\Contracts\Group|null
  * @throws MetaGroupNotFoundException
  */
 public function find($identifier, Variant $variant = null)
 {
     if ($variant) {
         if ($meta = Meta::where('identifier', $identifier)->where('variant_id', $variant->getKey())->where('variant_type', $variant->getType())->first()) {
             return $meta;
         }
     } else {
         if ($meta = Meta::where('identifier', $identifier)->first()) {
             return $meta;
         }
     }
     throw new MetaGroupNotFoundException('A meta group with the identifier "' . $identifier . '" could not be found.');
 }