Source of file WhereProvider.php
Size: 1,253 Bytes - Last Modified: 2021-12-23T10:02:17+00:00
/var/www/docs.ssmods.com/process/src/code/Providers/WhereProvider.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 | <?php namespace Seeder; use Exception; class WhereProvider extends Provider { /** * @var string */ public static $shorthand = 'where'; /** * @param mixed $field * @param mixed $state */ protected function generateField($field, $state) { throw new Exception('where provider does not support generating db fields'); } /** * @param mixed $field * @param mixed $state * * @return mixed */ protected function generateOne($field, $state) { $arguments = $field->options['arguments']; if (count($arguments) < 3) { throw new Exception('too few arguments'); } list($class, $key, $value) = $arguments; if (!class_exists($class)) { throw new Exception($class . ' does not exist'); } $object = $class::get()->filter($key, $value)->first(); if (is_null($object)) { throw new Exception('object not found'); } return $object; } /** * @param mixed $field * @param mixed $state * * @return mixed */ protected function generateMany($field, $state) { return $this->generateOne($field, $state); } } |