Level 63
Have you tried this ?
->layout('layouts.fluid');
1 like
I have a default layout set which works fine. I am trying to set up a 2nd layout to use for certain pages, but it does not seem to render in them, and still uses the default one. Thanks in advance!
I have tried using the render option:
return view('livewire.development.samples-list', ['samples' => $samples])->layout('fluid');
and the other option:
#[Layout('layouts.fluid')]
here is the layout file code:
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Nunito:400,600,700" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
@vite(['resources/sass/app.scss', 'resources/js/app.js'])
@if(isset($css) != NULL)
{{ $css }}
@endif
@if(auth()->user()->setting('open-dyslexia') == TRUE)
<style>
*{
font-family: 'opendyslexic';
font-size: 0.995em;
}
</style>
@endif
</head>
<body class="font-sans antialiased d-flex flex-column min-vh-100 bg-white">
<x-jet-banner />
<div id="headers" class="fixed-top mb-3">
@livewire('navigation-menu')
<!-- Page Heading -->
<header class="d-flex py-3 bg-white shadow-sm border-bottom">
<div class="container">
<div class="row">
<div class="col align-items-center">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ $title ?? config('app.name') }}
</h2>
</div>
<div class="col print align-middle">
<img style="height: 100px" class="img-thumbnail float-end bg-white border-0 m-0" src="https://roberttodds.com/images/robert_todd_logo_merino2.png" alt="Robert Todds">
</div>
</div>
</div>
</header>
</div>
<!-- Page Content -->
<main style="margin-bottom: 100px !important; margin-top:142px">
<div class="container-fluid py-4 bg-white">
<div class="row">
<div class="col">
@if (Session::get('message'))
<div class="alert {{ Session::get('alert-class') }}" role="alert">
{{ Session::get('message') }}
</div>
@endif
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</div>
</div>
<div class="row">
<div class="col">
{{ $slot }}
</div>
</div>
</div>
</main>
</body>
</html>
and the code for the livewire class:
<?php
namespace App\Http\Livewire\Development;
use App\Models\Styles;
use App\Models\Samples;
use App\Models\Seasons;
use Livewire\Component;
use App\Models\Customer;
use App\Models\Suppliers;
use App\Models\Departments;
use Livewire\WithPagination;
use Livewire\Attributes\Layout;
use Livewire\Attributes\Computed;
class SamplesList extends Component
{
use WithPagination;
protected $paginationTheme = 'bootstrap';
public $paginate = 200, $season, $customer, $factory, $category, $department, $search;
#[Computed]
public function seasons(){
return Seasons::get();
}
#[Computed]
public function customers(){
return Customer::whereHas('styles')->get();
}
#[Computed]
public function factories(){
return Suppliers::whereHas('style_versions')->get();
}
#[Computed]
public function departments(){
return Departments::get();
}
#[Layout('layouts.fluid')]
public function render()
{
$samples = Samples::select(
'styles.customer_ref',
'colourways.name as colourway',
'colourways.id as colourway_id',
'colourways.image',
'samples.id',
'sample_types.name as sample_type',
'styles.id as style_id',
'style_versions.name as style_version',
'style_versions.id as style_version_id',
'samples.date_sent',
'samples.tracking',
'samples.weight',
'sizes.name as size',
'samples.date_received',
'samples.status',
'samples.do_not_charge',
'samples.comments',
'samples.qty',
'samples.do_not_charge_dev',
'samples.fn_notes',
'samples.po')
->selectRaw('(SELECT COUNT(s.id) FROM samples s JOIN style_versions sv ON sv.id = s.style_versions_id WHERE sv.styles_id=styles.id) AS count_styles')
->join('sample_types', 'sample_types.id', '=', 'samples.sample_types_id')
->join('style_versions', 'style_versions.id', '=', 'samples.style_versions_id')
->join('styles', 'styles.id', '=', 'style_versions.styles_id')
->join('colourways', 'colourways.id', '=', 'samples.colourways_id')
->join('sizes', 'sizes.id', '=', 'samples.sizes_id')
->when(!empty($this->season),function($query){
$query->whereRelation('colourways.style_versions.styles', 'seasons_id', $this->season);
})
->when(!empty($this->customer),function($query){
$query->whereRelation('colourways.style_versions.styles', 'customers_id', $this->customer);
})
->when(!empty($this->factory),function($query){
$query->whereRelation('colourways.style_versions', 'factory_id', $this->factory);
})
->when(!empty($this->category),function($query){
$query->whereRelation('colourways.style_versions.styles', 'category', $this->category);
})
->when(!empty($this->department),function($query){
$query->whereRelation('colourways.style_versions.styles', 'departments_id', $this->department);
})
->orderBy('style_id')->orderBy('style_version_id')->orderBy('colourway_id')->orderBy('sample_type')
->paginate($this->paginate);
return view('livewire.development.samples-list', ['samples' => $samples])->layout('fluid');
}
}
@vincent15000 I had, but looking at it again I realised I'd been adding it to the nested component not the parent so it obviously wouldnt work, thanks for the promt!
Please or to participate in this conversation.