У меня выводится коллекцией, а нужно вывести построчно каждый отдельный проект отдельно поле названия отдельно сайт, отдельно теги, И так далее без лишних полей.
<div>
<h1>
{{ Lang::choice('projects.works', 1) }}
</h1>
@if($project ?? '' )
<x-project id="{{ $project['id'] }}" />
@endif
<ul class="projects-menu">
<li class="projects-menu-item">
<p class="projects-menu-link">
{{ $projects }}
</p>
</li>
</ul>
</div>
<?php
namespace App\View\Components;
use App\Models\Project;
use Illuminate\View\Component;
use Illuminate\Database\Eloquent\Collection;
class Projects extends Component
{
public Collection $projects;
public array $tags = [];
public $tag;
public function __construct()
{
$this->projects = Project::select('id')->published()->get();
$this->tags[] = [
'name' => __('projects.all_projects'),
'slug' => 'all',
];
$project = Project::where('id', 1)
->take(10)
->get();
foreach ($this->projects as &$project) {
$tags = $project->tags()->get();
foreach ($tags as &$tag)
$this->tags[] = [
'name' => $tag->name,
'slug' => $tag->slug,
];
}
}
public function render()
{
foreach ($this->projects as &$project) {
echo ( $projects ?? '');
echo ( $tags ?? '');
}
return view('components.projects')
->with('projects', $projects ?? '')
->with('tags', $tags ?? '');
}
}
<?php
namespace App\View\Components;
use App\Models\Project as ModelsProject;
use Illuminate\View\Component;
class Project extends Component
{
public $project;
public function __construct($id)
{
$project = Project::where('id', 1)->take(10)->get();
}
public function render()
{
foreach ($this->projects as &$project) {
echo ( $project ?? '');
}
return view('components.project.solid')
->with('project')
->with('colors');
}
}
@if($project)
<div style="background: {{ $colors[0] }}">
@if (!is_null($project->url))
<span>{{ $project->present()->urlHost() }}</span>
@endif
@if (!is_null($project->url))
<a href="{{ $project->url }}" target="_blank" class="stretched-link"></a>
@endif
</div>
@endif
Заранее спасибо