/** * Set attribute. * * @param string $attribute * @param mixed $value * * @return Attribute */ public function with($attribute, $value) { $attribute = Str::snake($attribute); if (!$this->validate($attribute, $value)) { throw new InvalidArgumentException("Invalid attribute '{$attribute}'."); } $this->set($attribute, $value); return $this; }
/** * Register service. * * @param Application $app * * @return mixed */ public function register(Application $app) { $app->singleton('message', function ($app) { return new MessageFactory($app); }); $messages = ['Text', 'Articles', 'Article', 'Image', 'Link', 'Location', 'Music', 'Transfer', 'ShortVideo', 'Video', 'Voice']; foreach ($messages as $message) { $app->bind('message.' . Str::snake($message), function ($app) use($message) { $class = __NAMESPACE__ . '\\' . $message; return new $class(); }, false); } }