本文整理汇总了PHP中Illuminate\Support\Str::contains方法的典型用法代码示例。如果您正苦于以下问题:PHP Str::contains方法的具体用法?PHP Str::contains怎么用?PHP Str::contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Str
的用法示例。
在下文中一共展示了Str::contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install
/**
* Install the components.
*
* @return void
*/
public function install()
{
if (Str::contains(file_get_contents(base_path('.env')), 'AUTHY_SECRET')) {
return;
}
(new Filesystem())->append(base_path('.env'), file_get_contents(SPARK_HEX_STUB_PATH . '/.env'));
}
示例2: rollback
public function rollback()
{
if (Str::contains($this->menuContents, $this->menuTemplate)) {
file_put_contents($this->path, str_replace($this->menuTemplate, '', $this->menuContents));
$this->commandData->commandComment('menu deleted');
}
}
示例3: get
/**
* Retorna informações do XML com base no caminho separado por ponto.
*
* @param $key
* @return XMLGet
*/
public function get($key)
{
if (Str::contains($key, '|')) {
$opcoes = explode('|', $key);
foreach ($opcoes as $op) {
$achado = $this->get($op);
if (!$achado->isNull()) {
return $achado;
}
}
return new XMLGet(null);
}
$base = $this;
$niveis = $key == '' ? [] : explode('.', $key);
foreach ($niveis as $i => $nivel) {
// Verificar se base eh nula
if (is_null($base)) {
return new XMLGet(null);
}
$elem = $base->getElementsByTagName($nivel);
$base = $elem->length > 0 ? $elem->item(0) : null;
}
// Retornar o conteúdo do ultimo nível
if (!is_null($base)) {
return new XMLGet($base);
}
return new XMLGet(null);
}
示例4: appendDisqusScript
/**
* Append disqus script on the end of the page.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Response $response
* @return mixed
*/
protected function appendDisqusScript($request, $response)
{
$content = $response->getContent();
if (!Str::contains($content, '<div id="disqus_thread"></div>')) {
return;
}
$uri = $request->getRequestUri();
$pageUrl = url($uri);
$pageId = 'route' . implode('.', explode('/', $uri));
$username = config('disqus.username');
$disqusHtml = <<<CDATA
<script>
var disqus_config = function () {
this.page.url = '{$pageUrl}';
this.page.identifier = '{$pageId}';
};
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = '//{$username}.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href=\\"https://disqus.com/?ref_noscript\\" rel=\\"nofollow\\">comments powered by Disqus.</a></noscript>
CDATA;
$bodyPosition = strripos($content, '</body>');
if (false !== $bodyPosition) {
$content = substr($content, 0, $bodyPosition) . $disqusHtml . substr($content, $bodyPosition);
}
$response->setContent($content);
}
示例5: handle
/**
* @param Message $message
* @return mixed
*/
public function handle(Message $message)
{
if ($message->user->login === \Auth::user()->login) {
return $message;
}
// Personal message
$isBotMention = $message->hasMention(function (User $user) {
return $user->login === \Auth::user()->login;
});
if ($isBotMention) {
//$this->ai->handle($message);
} else {
// Hello all
$isHello = Str::contains($message->text_without_special_chars, \Lang::get('personal.hello_query'));
if ($isHello) {
$id = array_rand(\Lang::get('personal.hello'));
$message->italic(\Lang::get('personal.hello.' . $id, ['user' => $message->user->login]));
}
// Question
$isQuestion = Str::contains($message->text_without_special_chars, ['можно задать вопрос', 'хочу задать вопрос']);
if ($isQuestion) {
$message->italic(sprintf('@%s, и какой ответ ты ожидаешь услышать?', $message->user->login));
}
}
return $message;
}
示例6: stripProtocol
/**
* Strip the protocol from a domain.
*
* @param string $domain
*
* @return string
*/
protected function stripProtocol($domain)
{
if (Str::contains($domain, '://')) {
$domain = substr($domain, strpos($domain, '://') + 3);
}
return $domain;
}
示例7: retrieveByCredentials
/**
* Retrieve a user by the given credentials.
*
* @param array $credentials
* @return \Illuminate\Contracts\Auth\Authenticatable|null
*/
public function retrieveByCredentials(array $credentials)
{
if (empty($credentials)) {
return null;
}
$index = null;
$values = null;
foreach ($credentials as $key => $value) {
if (!Str::contains($key, 'password')) {
$index = is_null($index) ? $key : $index . '_' . $key;
$values = is_null($values) ? [] : $values;
$values[] = $value;
}
}
if (is_null($index) || is_null($values)) {
return null;
}
$values = count($values) == 1 ? $values[0] : $values;
$result = $this->createModel()->newQuery()->getQuery()->r()->getAll($values, ['index' => $index])->run();
$result = $this->hydrate($result);
if ($result) {
$result = $result->first();
}
return $result;
}
示例8: view
/**
* @param $template
* @return \Illuminate\Contracts\View\View
*/
protected function view($template)
{
if (Str::contains($template, '::')) {
return $this->view->make($template);
} else {
return $this->view->make('admin::' . $template);
}
}
示例9: isRelationship
protected function isRelationship(ReflectionMethod $method)
{
if ($method->getNumberOfParameters()) {
return false;
}
$source = $this->getMethodSource($method);
return Str::contains($source, $this->getRelationshipStrings());
}
示例10: formatHelperName
protected function formatHelperName($helper)
{
$namespace = $this->app->getNamespace();
if (!Str::contains($helper, $namespace)) {
$helper = $namespace . 'Helpers\\' . $helper;
}
return $helper;
}
示例11: handle
public function handle(Request $request, Closure $next)
{
$agent = $request->header('User-Agent');
if ($agent && Str::contains($agent, $this->badUserAgents)) {
return abort(400);
}
return $next($request);
}
示例12: setActive
public static function setActive($path, $active = 'active')
{
//funcion para agregar la clase active en el menu del sistema
if (Str::contains(Request::capture()->path(), 'auth')) {
return '';
}
return Str::contains(Request::capture()->path(), $path) ? $active : '';
}
示例13: rollback
public function rollback()
{
if (Str::contains($this->routeContents, $this->routesTemplate)) {
$this->routeContents = str_replace($this->routesTemplate, '', $this->routeContents);
file_put_contents($this->path, $this->routeContents);
$this->commandData->commandComment('scaffold routes deleted');
}
}
示例14: processCommand
/**
* Apply modifiers to some commands before
* they're executed
*
* @param string $command
*
* @return string
*/
public function processCommand($command)
{
// Add environment flag to commands
$stage = $this->connections->getCurrentConnectionKey()->stage;
if (Str::contains($command, 'artisan') && $stage) {
$command .= ' --env="' . $stage . '"';
}
return $command;
}
示例15: fire
/**
* @param \Notadd\Foundation\Extension\ExtensionManager $manager
* @param \Notadd\Foundation\Setting\Contracts\SettingsRepository $settings
*
* @return bool
*/
public function fire(ExtensionManager $manager, SettingsRepository $settings)
{
$name = $this->input->getArgument('name');
$extensions = $manager->getExtensionPaths();
if (!$extensions->offsetExists($name)) {
$this->error("Extension {$name} do not exist!");
return false;
}
if (!$this->container->make(SettingsRepository::class)->get('extension.' . $name . '.installed')) {
$this->error("Extension {$name} does not installed!");
return false;
}
$extension = $extensions->get($name);
$path = $extension;
if (Str::contains($path, $manager->getVendorPath())) {
$this->error("Please update extension {$name} from composer command!");
return false;
}
$extensionFile = new JsonFile($path . DIRECTORY_SEPARATOR . 'composer.json');
$extension = collect($extensionFile->read());
if ($extension->has('autoload')) {
$autoload = collect($extension->get('autoload'));
$autoload->has('classmap') && collect($autoload->get('classmap'))->each(function ($value) use($path) {
$path = str_replace($this->container->basePath() . '/', '', realpath($path . DIRECTORY_SEPARATOR . $value)) . '/';
if (!in_array($path, $this->backup['autoload']['classmap'])) {
$this->backup['autoload']['classmap'][] = $path;
}
});
$autoload->has('files') && collect($autoload->get('files'))->each(function ($value) use($path) {
$path = str_replace($this->container->basePath() . '/', '', realpath($path . DIRECTORY_SEPARATOR . $value));
if (!in_array($path, $this->backup['autoload']['files'])) {
$this->backup['autoload']['files'][] = $path;
}
});
$autoload->has('psr-0') && collect($autoload->get('psr-0'))->each(function ($value, $key) use($path) {
$path = str_replace($this->container->basePath() . '/', '', realpath($path . DIRECTORY_SEPARATOR . $value)) . '/';
$this->backup['autoload']['psr-0'][$key] = $path;
});
$autoload->has('psr-4') && collect($autoload->get('psr-4'))->each(function ($value, $key) use($path) {
$path = str_replace($this->container->basePath() . '/', '', realpath($path . DIRECTORY_SEPARATOR . $value)) . '/';
$this->backup['autoload']['psr-4'][$key] = $path;
});
$this->json->addProperty('autoload', $this->backup['autoload']);
$settings->set('extension.' . $name . '.autoload', json_encode($autoload->toArray()));
}
if ($extension->has('require')) {
$require = collect($extension->get('require'));
$require->each(function ($version, $name) {
$this->backup['require'][$name] = $version;
});
$this->json->addProperty('require', $this->backup['require']);
$settings->set('extension.' . $name . '.require', json_encode($require->toArray()));
}
$this->updateComposer(true);
$this->info("Extension {$name} is updated!");
return true;
}