Я искал всю документацию и Интернет, чтобы найти, как это сделать.
Я вижу, что у Jetstream есть team-member-manager.php, где вы можете устанавливать новых участников и назначать им роли. Они могут перечислить это через это
<!-- Role -->
@if (count($this->roles) > 0)
<div class = "col-span-6 lg:col-span-4">
<x-jet-label for = "role" value = "{{ __('Role') }}" />
<x-jet-input-error for = "role" class = "mt-2" />
<div class = "mt-1 border border-gray-200 rounded-lg cursor-pointer">
@foreach ($this->roles as $index => $role)
<div class = "px-4 py-3 {{ $index > 0 ? 'border-t border-gray-200' : '' }}"
wire:click = "$set('addTeamMemberForm.role', '{{ $role->key }}')">
<div class = "{{ isset($addTeamMemberForm['role']) && $addTeamMemberForm['role'] !== $role->key ? 'opacity-50' : '' }}">
<!-- Role Name -->
<div class = "flex items-center">
<div class = "text-sm text-gray-600 {{ $addTeamMemberForm['role'] == $role->key ? 'font-semibold' : '' }}">
{{ $role->name }}
</div>
@if ($addTeamMemberForm['role'] == $role->key)
<svg class = "ml-2 h-5 w-5 text-green-400" fill = "none" stroke-linecap = "round" stroke-linejoin = "round" stroke-width = "2" stroke = "currentColor" viewBox = "0 0 24 24"><path d = "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
@endif
</div>
<!-- Role Description -->
<div class = "mt-2 text-xs text-gray-600">
{{ $role->description }}
</div>
</div>
</div>
@endforeach
</div>
</div>
@endif
теперь я хочу использовать этот вид материи на другом лезвии, но я не могу понять, откуда $this->roles.
Спасибо






Этот код приводит в действие лезвие, которое вы хотели.
Итак, как вы можете видеть, в коде происходит волшебство, я думаю, это называется динамическим свойством. Это означает, что когда у вас есть такой метод getRolesProperty(), вы можете получить к нему доступ через интерфейс, как это $this->roles;
/**
* Get the available team member roles.
*
* @return array
*/
public function getRolesProperty()
{
return array_values(Jetstream::$roles);
}
Вы можете просто скопировать компонент и изменить его по своему усмотрению, а затем вернуть свой собственный вид.