Answer the question
In order to leave comments, you need to log in
How to display data in blade?
The router connects the template: /resources/views/pages/projects.blade.php
@extends('layouts.app')
@section('title', $page->title)
@section('seo_title', $page->seo_title)
@section('seo_description', $page->seo_description)
@section('seo_keywords', $page->seo_keywords)
@if ($page->hasImage('seo_image', 'default'))
@section('seo_image', app()->make('url')->to($page->image('seo_image', 'default')))
@endif
@section('content')
<x-projects />
@endsection
<?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 function __construct()
{
$this->projects = Project::select('id')->published()->get();
$this->tags[] = [
'name' => __('projects.all_projects'),
'slug' => 'all',
];
foreach ($this->projects as &$project) {
$tags = $project->tags()->get();
foreach ($tags as &$tag)
$this->tags[] = [
'name' => $tag->name,
'slug' => $tag->slug,
];
}
}
public function render()
{
return view('components.projects');
}
}
<div>
<h1>{{ Lang::choice('projects.works', 1) }}</h1>
@if($project ?? '' )
<x-project id="{{ $project['id'] }}" />
@endif
</div>
<?php
namespace App\View\Components;
use App\Models\Project as ModelsProject;
use Illuminate\View\Component;
class Project extends Component
{
public function render()
{
return view('components.project.solid');
}
}
@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
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question