statamic / bootstrap problem with vertical align - php

im newbie about statamic,
im try to solve this code :
<div class="container">
<div class="intro">
<div class="row">
<div class="col-md-12">
<h2 class="title-uppercase text-white">{{ section_three_title }}</h2>
<div class="row-project-box row">
{{ relate:section_three_categories }}
{{ entries }}
<div class="col-project-box col-sm-6 col-md-4 col-lg-3">
<a href="{{ url }}" class="project-box">
<div class="project-box-inner">
<h5>{{ title }}</h5>
</div>
</a>
</div>
{{ /entries }}
{{ /relate:section_three_categories }}
</div>
view all projects <i class="icon icon-chevron-right"></i>
</div>
</div>
</div>
</div>
the code provide this :
i want to align these box
direzionale operativo dirigenziale not in horizonatal but in vertical like this:
direzionale
operativo
dirigenziale
i think that is a bootstrap configuration but i dont know about the statamic world
anyone can help me ?
thanks a lot

The problem here seems that you are using responsive breakpoints on your columns,
so if you want to set the boxes one below the other all the times you have to set the .col-project-box always be full-width adding this class col-12 and set the .row-project-box horizontal alignment center adding this class justify-content-center to it.
<div class="container">
<div class="intro">
<div class="row">
<div class="col-md-12">
<h2 class="title-uppercase text-white">{{ section_three_title }}</h2>
<div class="row-project-box row justify-content-center">
{{ relate:section_three_categories }}
{{ entries }}
<div class="col-project-box col-12">
<a href="{{ url }}" class="project-box">
<div class="project-box-inner">
<h5>{{ title }}</h5>
</div>
</a>
</div>
{{ /entries }}
{{ /relate:section_three_categories }}
</div>
view all projects <i class="icon icon-chevron-right"></i>
</div>
</div>
</div>

Related

materializecss carousel center align unknown number of cards

I have a laravel 8 project with materializecss carousel with cards. The carousel is showing 5 items by default. If I have 5 items or more in the DB, then everything is fine. However with less than 5 items, the items are stacking on the left. I need them to be centered all the time doesnt matter the count of them. Here is my code:
<div class="col s12 l12 center">
<div class="carousel center">
#foreach($properties as $property)
<div class="carousel-item col m4 s8 l3">
<div class="card sticky-action borders-top borders-bottom" style="height: 400px;">
<div class="card-image waves-effect waves-block waves-light" style="height: 50%;">
#if($property->cover() != NULL)
<img class="activator" src="{{ url($property->cover()) }}" alt="office" style="height: 100%;" />
#endif
</div>
<div class="card-content activator">
<p class="activator">#foreach($property->locations as $location)
{{ $location->name }}
#endforeach </p>
<span class="card-title activator grey-text text-darken-4"> {{ $property->property_address }}
<p class="activator"> {{ $property->starting_price }} kr</p>
</span>
<p class="activator">{{ $property->propertyType->name }} - {{ $property->m2 }} kvm, {{ $property->size }}</p>
<p class="activator">{{ $property->plot_size }} kvm tomt</p>
<div class="card-action">
<span class="activator left viewing">Visas: {{ \Carbon\Carbon::parse($property->viewing_date)->isoFormat('ddd D/M') }}</span>
<span class="activator right viewing_date bostadonline-text mr-1">Mer Info...</span>
</div>
</div>
<div class="card-reveal">
<span class="card-title grey-text text-darken-4"> {{ $property->property_address }} <i class="material-icons right">close</i>
<p class="activator"> {{ $property->starting_price }} kr</p>
</span>
<p> {{ $property->short_description }} </p>
<p class="center"> Lägg bud </p>
</div>
</div>
</div>
#endforeach
</div>
</div>
Well I was overcomplicating things. I had set fullWidth on carousel to true and that messed things up. Then I had added some unnecessairy css modifcations that I had to remove. Basically, the solution was to set fullWidth to false on carousel properties. I didn't need to change my code on the question.

Problem with generating one extra slide using PHP FOR loop in Laravel Blade

I have a strange problem in Blade. I think is something obvious but I'm just stuck at it.
I have a Bootstrap carousel with cards in Larvel Blade view. I'm creating new "carousel-item" (slides) using if in for loop, but I'm facing the problem that it generates one empty slide. I cant figure it out why this is happening.
The following code should generate 2 slides with 4 cards in it. Unfortunately it creates 3 slides the last of them empty.
This is my code:
<div id="carousel{!! $type !!}" class="carousel slide" data-ride="carousel" data-touch="true">
<div class="carousel-inner">
<div class="carousel-item active">
<div class="row justify-content-center latest__properties_row">
#for($i=0;$i<=7;$i++)
#if(isset($latest[$type][$i]))
<div class="col-md-3 mb-3 latest__properties">
<div class="card">
#if(isset($latest[$type][$i]['photos']))
#if(isset($latest[$type][$i]['photos'][0]))
<a href="/properties/{!! $latest[$type][$i]['slug'] !!}"><img
class="img-fluid latest__properties__photo"
alt="{!! $latest[$type][$i]['title'] !!}"
src="/images/properties/{!! $latest[$type][$i]['photos'][0]['url'] !!}"></a>
#endif
#endif
<div class="card-body">
<div class="title">
<a href="/properties/{!! $latest[$type][$i]['slug'] !!}"><h4
class="card-title">{!! $latest[$type][$i]['title'] !!}</h4>
</a>
</div>
<!-- Slide like buttom -->
<button class="slide__like-btn">
<i class="far fa-heart"></i>
</button>
<!-- Slide badge -->
#if(isset($latest[$type][$i]['terms']['property_labels']))
#for($k=0;$k<=count($latest[$type][$i]['terms']['property_labels']);$k++)
#if(isset($latest[$type][$i]['terms']['property_labels'][$k]))
<div class="slide__badge {!! ($latest[$type][$i]['terms']['property_labels'][$k]['attributes'] != '' || $latest[$type][$i]['terms']['property_labels'][$k]['attributes'] != null) ? $latest[$type][$i]['terms']['property_labels'][$k]['attributes'] : '' !!} text-uppercase">
{!! $latest[$type][$i]['terms']['property_labels'][$k]['name'] !!}
</div>
#endif
#endfor
#endif
<ul>
#if(isset($latest[$type][$i]['rooms']) && $latest[$type][$i]['rooms'] != 0)
<li><b>Стаи:</b> {!! $latest[$type][$i]['rooms'] !!}</li>
#endif
#if(isset($latest[$type][$i]['bathrooms']) && $latest[$type][$i]['bathrooms'] != 0)
<li><b>Бани:</b> {!! $latest[$type][$i]['bathrooms'] !!}
</li>
#endif
#if(isset($latest[$type][$i]['sqm']) && $latest[$type][$i]['sqm'] != 0)
<li><b>Квадратура:</b> {!! $latest[$type][$i]['sqm'] !!} m²</li>
#endif
</ul>
<p class="latest__properties__id">
ID: {!! $latest[$type][$i]['unique_code'] !!}</p>
<p class="latest__properties__price">
<span class="euro">€ {!! $latest[$type][$i]['price'] !!}</span>
<span
class="bgn">{!! $latest[$type][$i]['price_bgn'] !!} лв.</span>
</p>
<p class="latest__properties__created__at">
{!! $latest[$type][$i]['created_at'] !!}
</p>
</div>
</div>
</div>
#if($i == 3)
</div>
</div>
<div class="carousel-item">
<div class="row justify-content-center latest__properties_row">
#endif
#endif
#endfor
</div>
</div>
<div class="carousel-item">
<div class="row justify-content-center latest__properties_row">
</div>
</div>
</div>
</div>
I just figured it out... I was looking like 1000 times the code and that I realize I just forgot an empty slide right after the for loop.

expand / toggle div with display none from foreach with $ id

I have this:
#foreach($portfolios as $portfolio)
<div id="item-portfolio-expand{{$portfolio->id}}" class="item-portfolio-expand expand">
<div class="container">
<div class="row">
<div class="col-md-8">
col-md-8
</div>
<div class="col-md-4">
{{ __('Name')}}: {{ $portfolio->name }}
</div>
</div>
</div>
</div>
#endforeach
And this:
#foreach ($portfolios as $portfolio)
<div class="portfolio-item {{ $portfolio->tag }} " data-category="transition">
<img src="{{ $portfolio->image_show }}">
<a href="#item-portfolio-expand{{$portfolio->id}}" data-toggle="collapse" data-target="#item-portfolio-expand{{$portfolio->id}}" data-parent="#item-portfolio-expand{{$portfolio->id}}">
<div class="portfolio-item-overlay">
<p class="name-item-overlay">{{ $portfolio->name }}</p>
</div>
</a>
</div>
#endforeach
And when I press the in the first foreach, I want to toggle the second foreach at <div id = "item-portfolio-expand {{$ portfolio-> id}}" class = "item- portfolio-expand expand "> I just don't succeed at anything, I use bootstrap and jquery in the project. .item-portfolio-expand has display: none;
And at the same time when one is open and another is selected, to close the one already open and to appear the one selected with toggle.

Laravel : How to divide a file into multiple files?

How to divide a file into multiple files with laravel or php?
For example:
There is a file demo.blade.php:
<div class="card-block">
<div class="row">
<div class="col-1">fruits</div>
<div class="col-11">
apple,pear,peach
</div>
</div>
</div>
<div class="card-block">
<div class="row">
<div class="col-1">aminals</div>
<div class="col-11">
cat,dog,calf
</div>
</div>
</div>
<div class="card-block">
<div class="row">
<div class="col-1">vehicles</div>
<div class="col-11">
car,bus,motorbike
</div>
</div>
</div>
I want to write some code to divide the demo.blade.php into three files:
fruits.blade.php
aminals.blade.php
vehicles.blade.php
The content is each <div class="card-block"></div>.
How to do it?
Any help would be appreciated.
You can use other blade in your blade file like this :
#include('fruits.blade.php')
#include('aminals.blade.php')
#include('vehicles.blade.php')
But this is not a good idea. Instead you can make a template like this :
<div class="card-block">
<div class="row">
<div class="col-1">{{ $title }}</div>
<div class="col-11">
{{ $content }}
</div>
</div>
</div>
And use it everywhere :
#include('template', ['title' => 'foo', 'content' => 'bar'])
Anyway I don't know your purpose of doing this. And you can explain more to give you more examples.
You can also use Blade Components
//This is the template cardblock.blade.php
<div class="card-block">
<div class="row">
<div class="col-1">{{ $title }}</div>
<div class="col-11">
{{ $slot }}
</div>
</div>
</div>
And you can use it like this
#component('cardblock')
#slot('title')
fruits
#endslot
apple,pear,peach
#endcomponent
#component('cardblock')
#slot('title')
aminals
#endslot
cat,dog,calf
#endcomponent
#component('cardblock')
#slot('title')
vehicles
#endslot
car,bus,motorbike
#endcomponent

Laravel multipule relationships count

I have these models:
ForumCategory
Forum
Topic
Reply
In the main forum page, I want to count and display the number of replies that associated to this forum.
All the models have relationships.
This is the view:
#foreach ($categories as $category)
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default striped">
<div class="panel-heading">
<div class="row">
<div class="col-md-11">{{ $category->name }}</div>
<div class="col-md-1 text-right"><a><span class="fa fa-arrow-down"></span></a></div>
</div>
</div>
#foreach ($category->forums as $forum)
<div class="panel-body">
<div class="row">
<div class="col-md-1 text-right"><span class="fa fa-envelope fa-4x"></span></div>
<div class="col-md-7">
<h4>
{{ $forum->name }}
<br>
<small>{{ $forum->description }}</small>
</h4>
</div>
<div class="col-md-1 post-num">
<h5>{{ $forum->topics->count() }}<br>
<small>Topics</small></h5>
<h5>{{ $forum->topics->replies->count() }}<br>
<small>Replies</small></h5>
</div>
<div class="col-md-3">
<img src="" class="img-circle last-comnt-img">
Last comment<br>
By Username<br>
<span class="text-muted">12:31</span>
</div>
</div>
</div>
#endforeach
</div>
</div>
</div>
</div>
#endforeach
This line won't work:
$forum->topics->replies->count()

Categories