Laravel 8 basename {#collection-method}
basename
方法将返回指定字符串的结尾部分:
use Illuminate\Support\Str;
$string = Str::of('/foo/bar/baz')->basename();
// 'baz'
如果有必要,您亦可提供提供一个「扩展名」,将从尾部的组件中移除它。
use Illuminate\Support\Str;
$string = Str::of('/foo/bar/baz.jpg')->basename('.jpg');
// 'baz'