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.
Related
I am doing a live search on livewire, my search term is already binded with the livewire controller, but when I add it to the where clause in render function, it still displays all the data on the table not the one i am searching. I tried replacing the searchterm with a string as keyword in LIKE and it works. It seems that i can't use the input in searchterm as a keyword in the where clause.
here is my controller;
<?php
namespace App\Http\Livewire;
use Livewire\Component;
use App\Models\Item;
use Livewire\WithPagination;
class Items extends Component
{
use WithPagination;
public $searchTerm;
public function render()
{
$select = Item::where('itemName', 'LIKE', '%' . $this->searchTerm . '%')->paginate(6);
return view('livewire.items', ['items' => $select]);
}
}
this is my view
<div class="row browse mt-6">
<div class="col float-left category ">
<h4 class="float-left font-weight-bold">All Categories</h4>
<h4 class="float-left font-weight-bold">Men</h4>
<h4 class="float-left font-weight-bold">Women</h4>
</div>
<div class="col search-cat float-right">
<input type="text" id="search" placeholder="Browse Products" wire:model="searchTerm"/>
</div>
{{$searchTerm}}
</div>
<hr style="border-top: dotted 1px;" />
<div class="row w-100 p-1">
<table class="table-center">
<tbody>
<div>
#foreach($items as $item)
<tr class="mx-auto">
<div class="d-inline w-30 item-desc mx-auto m-1">
<h4 class="pt-1">{{ $item->itemName }}</h4>
<div class="">
<img src="items/{{ $item->itemPic }}.png" alt="" class="item-pic">
</div>
<div class="row">
<div class="col d-inline float-left">
Price: US ${{ $item->itemPrice }}
</div>
<div class="col d-inline float-right">
{{ $item->itemCOD }}</td>
</div>
</div>
</div>
</tr>
</tbody>
#endforeach
</div>
<hr style="border-top: dotted 1px;" />
<div class="pagination-content">
{{ $items->links('pagination::pagination-custom') }}
</div>
<hr style="border-top: dotted 1px;" />
</table>
</div>
There's two things here that could potentially cause problems,
Your tr element does not have wire:key, the value to wire:key must be unique across the entire page
Your view consists of multiple root elements (if this is your entire view), these are the three root-elements in your view - and in Livewire, its very important that the view only has one root element.
<div class="row browse mt-6">
<hr style="border-top: dotted 1px;" />
<div class="row w-100 p-1">
Also, as a sidenote, your loop also closes the tbody tag, which is odd, so I moved that out of the loop. It also doesn't quite make sense to put divs and hrs inside the table tag, those should probably be outside of the tabletag.
Here's the updated view, with wire:key on the tr and with the whole view wrapped in one div,
<div>
<div class="row browse mt-6">
<div class="col float-left category ">
<h4 class="float-left font-weight-bold">All Categories</h4>
<h4 class="float-left font-weight-bold">Men</h4>
<h4 class="float-left font-weight-bold">Women</h4>
</div>
<div class="col search-cat float-right">
<input type="text" id="search" placeholder="Browse Products" wire:model="searchTerm"/>
</div>
{{$searchTerm}}
</div>
<hr style="border-top: dotted 1px;" />
<div class="row w-100 p-1">
<table class="table-center">
<tbody>
<div>
#foreach($items as $item)
<tr class="mx-auto" wire:key="item-{{ $item->id }}">
<div class="d-inline w-30 item-desc mx-auto m-1">
<h4 class="pt-1">{{ $item->itemName }}</h4>
<div class="">
<img src="items/{{ $item->itemPic }}.png" alt="" class="item-pic">
</div>
<div class="row">
<div class="col d-inline float-left">
Price: US ${{ $item->itemPrice }}
</div>
<div class="col d-inline float-right">
{{ $item->itemCOD }}</td>
</div>
</div>
</div>
</tr>
#endforeach
</div>
</tbody>
<hr style="border-top: dotted 1px;" />
<div class="pagination-content">
{{ $items->links('pagination::pagination-custom') }}
</div>
<hr style="border-top: dotted 1px;" />
</table>
</div>
</div>
Have a look at this resource from the official Livewire docs,
https://laravel-livewire.com/docs/2.x/troubleshooting#dom-diffing-issues
Maybe because you not render component
Try add <livewire:name-component /> in parent view like this
<div class>
<livewire:name-component />
</div>
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.
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.
I'm trying to create an "updatable" order list|table where the user can change one dropdown value of the list to "take in charge" all orders listed.
(PS: user will also have the possibility to filter the list in order to take in charge only specific orders | order-row checkboxes will be removed since not necessary).
I have created my controller (using not Eloquent but query builder to query the data).
I'm passing my data to my view.
I can view the expected records in the list|table.
User can choose his name into the first order row dropdown called "Prise en charge", then all other order rows dropdowns values are changed accordingly :
https://www.screencast.com/t/Ei1wdJtb
(link works with Mozilla and Chrome but not Opera)
Now I would like to update with submit all in the table listed orders.
I know how to create CRUDs, but I never created this kind of hybrids, so it is a little bit unclear (or completely honestly said) how to do it.
I would appreciate some expertise about what is missing to submit and update accordingly the database table columns.
CONTROLLER
<?php namespace App\Http\Controllers;
use Session;
use Request;
use DB;
use CRUDBooster;
Use SoftDelete;
class AdminLaboOrdersManagementController extends Controller {
public function updateOrder(Request $request) {
# QUERIES
# I haven't printed the queries since it is not relevant I guess and
# because it takes a lot of space. If needed I will of course provide ...
# SEND TO VIEW
return view('labo_orders_mgt_view_index',
compact('staffs','orders','statusorders'));
}
}
BLADE
Structure
row-id is the row id of the order into the table
<div class="order" row-id="1029">rows and data</div>
<div class="order" row-id="1039">rows and data</div>
<div class="order" row-id="1049">rows and data</div>
<div class="order" row-id="1059">rows and data</div>
<div class="order" row-id="1060">rows and data</div>
<div class="order" row-id="1062">rows and data</div>
Code
#extends('crudbooster::admin_template')
#section('content')
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="{{ asset('assets/js/laboratory/takeCareOf.js')}}"></script>
<table class='table table-striped table-bordered'>
<tbody>
{{--dd($staffs)--}}
{{--dd($orders)--}}
<!-- FOREACH LOOP TO DISPLAY THE ORDERS -->
<form method="POST" action="" id="takecareof">
<div class='row button'>
<button type="submit" class="btn btn-primary btn-sm" id="btnFront" style="cursor: pointer;font-size:24px; height:47px;width:100%;"> Je confirme la prise en charge </button>
</div>
#foreach($orders as $order)
<div class="order" row-id="{{$order->rowID}}">
<div class="col-md-1 sub_chkbox">
<input type="checkbox" class="sub_chk" data-id="{{$order->rowID}}">
</div>
<div class="row">
<div class="col-md-2 takecareof">
<h5>Prise en charge par</h5>
<p>
<select name="dropdownlabostaffs" class="dropdownlabostaffs form-control">
#if (isset($staffs))
<option value="">Artisans</option>
#foreach ($staffs as $staff)
<option value="{{ $staff->staffID }}"{{ $staff->staffID == $order->ownerID ? 'selected' : '' }}>{{ $staff->staffName }}</option>
#endforeach
#endif
</select>
</p>
</div>
</div>
#if($order->FirstnameUser === NULL || $order->LastnameUser === NULL)
<div class="row">
<div class="col-md-2 ordernr">
<h5>Commande no</h5>
<p>
{{ $order->orderID }}
</p>
</div>
<div class="col-md-3 orderby">
<h5>Commandé par</h5>
<p>
#if(isset($order->FirstnameUser)) {{ $order->FirstnameUser }} #endif #if(isset($order->LastnameUser)) {{ $order->LastnameUser }} #endif
</p>
</div>
<div class="col-md-3 forcustomer">
<h5>Pour Client</h5>
<p>
#if(isset($order->FirstnameCustomer)) {{ $order->FirstnameCustomer }} #endif #if(isset($order->LastnameCustomer)) {{ $order->LastnameCustomer }} #endif
</p>
</div>
<div class="col-md-3 laboratory">
<h5>Laboratoire</h5>
<p>
{{ $order->Laboratory }}
</p>
</div>
</div>
#else
<div class="row">
<div class="col-md-2 ordernr">
<h5>Commande no</h5>
<p>
{{ $order->orderID }}
</p>
</div>
<div class="col-md-3 orderby">
<h5>Commandé par</h5>
<p>
#if(isset($order->FirstnameUser)) {{ $order->FirstnameUser }} #endif #if(isset($order->LastnameUser)) {{ $order->LastnameUser }} #endif
</p>
</div>
<div class="col-md-3 forcustomer">
<h5>Pour Client</h5>
<p>
#if(isset($order->FirstnameCustomer)) {{ $order->FirstnameCustomer }} #endif #if(isset($order->LastnameCustomer)) {{ $order->LastnameCustomer }} #endif
</p>
</div>
<div class="col-md-3 laboratory">
<h5>Laboratoire</h5>
<p>
{{ $order->Laboratory }}
</p>
</div>
</div>
#endif
<div class="row">
<div class="col-md-6 status">
<h5>Statut</h5>
<p>
<select name="statusorder" class="statusorder form-control">
#if (isset($statusorders))
<option value="">Status</option>
#foreach ($statusorders as $statusorder)
<option value="{{ $statusorder->statusorderID }}"{{ $statusorder->statusorderID == $order->StatusID ? 'selected' : '' }}>{{ $statusorder->statusorderName }}</option>
#endforeach
#endif
</select>
</p>
</div>
<div class="col-md-6 pickup">
<h5>Date | heure de retrait</h5>
<p>
{{ date('d-m-Y', strtotime($order->{'DeliveryDate'})) }} | 13:15
</p>
<p>
</p>
</div>
</div>
<div class="row">
<div class="col-md-2 category">
<h5>Catégorie</h5>
<p>
#if(isset($order->Type)) {{ $order->Type }} #endif
</p>
</div>
<div class="col-md-2 product">
<h5>Produit</h5>
<p>
#if(isset($order->Name)) {{ $order->Name }} #endif
</p>
</div>
#if($order->Type === 'Gâteaux' || $order->Type === 'Tarte' || $order->Type === 'Tarte-fine')
<div class="col-md-2 servings">
<h5># Personnes</h5>
<p>
#if(isset($order->Servings)) {{ $order->Servings }} #endif
</p>
</div>
#endif
#if($order->Type === 'Gâteaux' || $order->Type === 'Tarte' || $order->Type === 'Tarte-fine')
<div class="col-md-2 chocodeco">
<h5>Déco Choco</h5>
#if(strpos($order->DecoChocoFruits, 'souhaitée') !== false)
<p>Oui</p>
#else
<p>Non</p>
#endif
</div>
<div class="col-md-4 flowerdeco">
<h5>Déco Fleurs</h5>
#if(strpos($order->DecoSmallFlowers, 'souhaitée') !== false)
<p>Oui</p>
#else
<p>Non</p>
#endif
</div>
#endif
#if($order->Type === 'Pain-surprise')
<div class="col-md-2 weight">
<h5>Poids</h5>
<p>
#if(isset($order->Weight)) {{ $order->Weight }} #endif
</p>
</div>
<div class="col-md-4 colorribbon">
<h5>
Couleur Ruban
</h5>
<p>
#if(isset($order->RibbonColor)) {{ $order->RibbonColor }} #endif
</p>
</div>
#endif
#if($order->Type === 'Pain')
<div class="col-md-2 breadquantity">
<h5>
Quantité
</h5>
<p>
#if(isset($order->BreadQuantity)) {{ $order->BreadQuantity }} #endif
</p>
</div>
<div class="col-md-6 slicecut">
<h5>
Coupe
</h5>
#if(strpos($order->Cut, 'souhaitée') !== false)
<p>Oui</p>
#else
<p>Non</p>
#endif
</div>
#endif
#if($order->Type === 'Salé')
<div class="col-md-2 savouryquantity">
<h5>
Quantité
</h5>
<p>
#if(isset($order->SavouryQuantity)) {{ $order->SavouryQuantity }} #endif
</p>
</div>
<div class="col-md-6 savouryassortment">
<h5>
Assortiment
</h5>
<p>
#if(isset($order->CanapésAssortment)) {{ $order->CanapésAssortment }} #endif
#if(isset($order->MiniPuffsAssortment)) {{ $order->MiniPuffsAssortment }} #endif
#if(isset($order->VolsAuVentAssortment)) {{ $order->VolsAuVentAssortment }} #endif
#if(isset($order->AppetisersAssortment)) {{ $order->AppetisersAssortment }} #endif
</p>
</div>
#endif
#if($order->Type === 'Sucré')
<div class="col-md-2 sweetquantity">
<h5>
Quantité
</h5>
<p>
#if(isset($order->SweetQuantity)) {{ $order->SweetQuantity }} #endif
</p>
</div>
<div class="col-md-6 sweetassortment">
<h5>
Coupe
</h5>
<p>
#if(isset($order->SweetAssortment)) {{ $order->SweetAssortment }} #endif
</p>
</div>
#endif
</div>
<div class="row">
#if($order->Type === 'Pain-surprise')
<div class="col-md-3 variante1">
<h5>
Assortiment 1
</h5>
<p>
#if(isset($order->Assortment1)) {{ $order->Assortment1 }} #endif
</p>
</div>
<div class="col-md-3 variante2">
<h5>
Assortiment 2
</h5>
<p>
#if(isset($order->Assortment2)) {{ $order->Assortment2 }} #endif
</p>
</div>
<div class="col-md-3 variante3">
<h5>
Assortiment 3
</h5>
<p>
#if(isset($order->Assortment3)) {{ $order->Assortment3 }} #endif
</p>
</div>
<div class="col-md-3 variante4">
<h5>
Assortiment 4
</h5>
<p>
#if(isset($order->Assortment4)) {{ $order->Assortment4 }} #endif
</p>
</div>
#endif
</div>
</div>
#endforeach
</form>
</tbody>
</table>
<!-- ADD A PAGINATION -->
<p></p>
#endsection
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>