Laravel 8 contains {#collection-method}
contains
方法判断指定字符串中是否包含另一指定字符串(区分大小写):
use Illuminate\Support\Str;
$contains = Str::of('This is my name')->contains('my');
// true
您亦可以传递数组的值的形式来判断指定字符串是否包含数组中的任一值:
use Illuminate\Support\Str;
$contains = Str::of('This is my name')->contains(['my', 'foo']);
// true