{$method}()); return $type; } /** * Set created at & updated at to now in array * @param $array * @return mixed */ public static function setDatesInArray($array) { $result = []; foreach ($array as $arr) { $arr['updated_at'] = Carbon::now(); $arr['created_at'] = Carbon::now(); $result[] = $arr; } return $result; } /** * Remove values from array * @param $array * @param array $values * @return array */ public static function removeValues($array,$values = []){ return array_diff($array,$values); } public static function array_search_key( $needle_key, $array ) { foreach($array AS $key=>$value){ if($key == $needle_key) return $value; if(is_array($value)){ if( ($result = self::array_search_key($needle_key,$value)) !== false) return $result; } } return false; } public static function relationships($model) { $relationships = []; foreach ((new ReflectionClass($model))->getMethods(ReflectionMethod::IS_PUBLIC) as $method) { if ($method->class != get_class($model) || !empty($method->getParameters()) || $method->getName() == __FUNCTION__) { continue; } try { $return = $method->invoke($model); if ($return instanceof Relation) { $relationships[$method->getName()] = [ 'type' => (new ReflectionClass($return))->getShortName(), 'model' => (new ReflectionClass($return->getRelated()))->getName(), ]; } } catch (ErrorException $e) { } } return $relationships; } }