create class and object of that in laravel 5.3 - php

I am using laravel 5.3 for my project. I have a panel bootstrap that have some cart in that. each cart has some feature. i want to define a cart class and create new object of that with button using jquery.
I am new in laravel.
I found, i can use #include for use cart in my code,but i cant change parameter of that.
How can i do that?
Main.blade.php:
<div class="col-md-6">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#AddGorohkary">add</button>
</div>
<div class="row" >
<div class="col-md-12" >
<ul class="horizontal-slide" dir="ltr" >
#include("Panel")
</ul>
</div>
</div><!-- row -->
Panel.blade.php:
<li class="col-md-3" >
<div class="panel panel-primary" >
<div class="panel-heading">
<div class="row">
<div data-toggle="tooltip" data-placement="bottom" title="حذف این گروه کاری" class="col-md-1 col-sm-1 col-xs-1 col-lg-1 col-md-offset-1">
<button onclick=" remove_entry($(this).parent().parent().parent().parent());" style="color: black;" type="button" class="close" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div data-toggle="tooltip" data-placement="bottom" title="تنظیمات" class="col-md-1 col-sm-1 col-xs-1 col-lg-1">
<span data-toggle="modal" data-target="#SettingModal" dir="rtl" style="color: black;" class=" glyphicon glyphicon-cog " aria-hidden="false"></span>
</div>
<div data-toggle="tooltip" data-placement="bottom" title="باز کردن صفحه گروه کاری" class="col-md-1 col-sm-1 col-xs-1 col-lg-1">
<a style="color: black;" href='/SpecialGoruhKary'><span class='glyphicon glyphicon-export' aria-hidden="false"></span></a>
</div>
<div data-toggle="tooltip" data-placement="bottom" title="اضافه کردن دانش آموز جدید" class="col-md-1 col-sm-1 col-xs-1 col-lg-1">
<span style="color: green;" class="glyphicon glyphicon-plus" aria-hidden="false"></span>
</div>
<div class="col-md-5 col-sm-5 col-xs-5 col-lg-5">
<span>#yield("GorohKarbariName")</span>
</div>
</div>
</div>
<div class="panel-body" style=" overflow-y: scroll;" >
#yield("table_body")
</div>
</div>
</li>
<!---------------------------------- Modal ---------------------------------------------------->
<div id="SettingModal" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">
<!-- Modal content-->
<div class="modal-content">
<div dir="rtl" class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title ">مشخصات این گروه کاری</h4>
</div>
<div class="modal-body">
<form dir="rtl" class="form-horizontal" action="{{ url('image-upload') }}" enctype="multipart/form-data" method="post" id="viewGorohkaryForm" >
{{ csrf_field() }}
<!-- Text input-->
<div class="form-group">
<div class="col-md-5 col-md-offset-3 inputGroupContainer">
<div dir="ltr" class="input-group">
<input dir="rtl" id="GorohKaryName" name="GorohKaryName" placeholder="اسم گروه کاری" class="form-control" type="text">
<span class="input-group-addon"><i class="glyphicon glyphicon-tag"></i></span>
</div>
</div>
<label for="GorohKaryName" class="col-md-2 control-label">اسم گروه کاری <span style="color: red">*</span> </label>
</div>
<!-- Text input-->
<div class="row col-md-offset-3">
<div class="form-group col-md-3">
<div class=" inputGroupContainer">
<div class=" clockpicker" data-placement="left" data-align="top" data-autoclose="true">
<div dir="ltr" class="input-group">
<input id="ValidTime" type="text" class="form-control" value="08:00">
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
</div>
</div>
</div>
<div class="form-group col-md-4 ">
<div class=" inputGroupContainer">
<div dir="ltr" class="input-group col-md-offset-1">
<select style="direction: rtl;" class="form-control" id="day" name="day" required="required">
<option value="" data-hidden="true">روز هفته</option>
<option value="0">شنبه</option>
<option value="1">یکشنبه</option>
<option value="2">دوشنبه</option>
<option value="3">سه شنبه</option>
<option value="4">چهارشنبه</option>
<option value="5">پنجشنبه</option>
<option value="6">جمعه</option>
</select>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<div class="form-group col-md-2">
<div class=" inputGroupContainer">
<div dir="ltr" class="input-group">
<button type="button" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span>
</button>
</div>
</div>
</div>
<label for="ValidTime" class="col-md-2 control-label" >زمان معتبر<span style="color: red">*</span> </label>
</div><!-- row clock-->
</form>
</div><!---modal body--->
<div class="modal-footer">
<button id="CreateNewGorohkary" type="submit" class="btn btn-warning" data-dismiss="modal">ذخیره <span class="glyphicon glyphicon-save"></span></button>
</div>
</div><!-- modal content-->
</div>
</div>

You can use of Including Sub-Views section of this link.
In that link you can see how send parameter to an include page.

Related

How do I get two modals to work on the same page?

I have a food ordering web app in PHP laravel 5.8. The items modal is working fine with the following code but when I am trying to display the deals modal in the same manner, it does not work at all. I am sharing my blade files. The "show.blade.php" file displays the entire front page where these modals have to be shown to the customer. The "modal.blade.php" file is where the modals are defined and their data is coming from the "show.blade.php" page. The first div in the modals file is the one that I want to work and the second is the one that is currently working fine. You can ignore the last modal div.
show.blade.php
#extends('layouts.front', ['class' => ''])
<?php
use Carbon\Carbon;
use App\User;
$name = new User();
?>
#section('content')
#include('restorants.partials.modals')
<section class="section pt-lg-0" id="restaurant-content" style="padding-top: 0px">
<input type="hidden" id="rid" value="{{ $restorant->id }}" />
<div class="container container-restorant">
<hr>
#if ($deals)
<div class="owl-carousel owl-theme owl-loaded">
<div class="owl-stage-outer">
<div class="owl-stage">
<h1>Deals</h1>
#foreach ($deals as $deal)
<div class="col-xl-3 col-lg-6 col-md-6 col-sm-6">
<div class="owl-item">
<div id="addToCart1">
<div class="strip">
<figure style="border-radius: 3rem">
<a onClick="setCurrentDeal({{ $deal->id }})" href="javascript:void(0)"><img
src="{{ $deal->image_url }}_thumbnail.jpg" loading="lazy"
data-src="{{ config('global.restorant_details_image') }}"
class="img-fluid lazy" alt=""></a>
</figure>
<span class="res_title"><b><a onClick="setCurrentDeal({{ $deal->id }})"
href="javascript:void(0)">{{ $deal->name }}</a></b></span><br />
<span class="res_description">{{ $deal->description }}</span><br />
<div class="d-flex justify-content-between">
<div>
#php
$dealItems = [];
$dealItems = App\DealItem::where('deal_id', $deal->id)->get();
#endphp
#foreach ($dealItems as $it)
<h6><strong>{{ $it->item->name }}</strong></h6>
#endforeach
</div>
<h6 class="text-success"><strong>Price:{{ $deal->price }}</strong></h6>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="owl-dots">
<div class="owl-dot active"><span></span></div>
<div class="owl-dot"><span></span></div>
<div class="owl-dot"><span></span></div>
</div>
</div>
#endforeach
#endif
</div>
#section('js')
<script>
$(function() {
$('.owl-carousel').owlCarousel({
margin: 50,
autoplay: true,
loop: true
});
});
var deals = [];
var currentDeal = null;
var currentDealSelectedPrice = null;
var lastAdded = null;
var CASHIER_CURRENCY = "<?php echo env('CASHIER_CURRENCY', 'usd'); ?>";
var LOCALE = "<?php echo App::getLocale(); ?>";
/*
* Price formater
* #param {Nummber} price
*/
function formatPrice(price) {
var formatter = new Intl.NumberFormat(LOCALE, {
style: 'currency',
currency: CASHIER_CURRENCY,
});
var formated = formatter.format(price);
return formated;
}
function setCurrentDeal(id) {
var deal = deals[id];
currentDeal = deal;
$('#modalDealTitle').text(deal.name);
$('#modalDealName').text(deal.name);
$('#modalDealPrice').html(deal.price);
$('#modalDealID').text(deal.id);
$("#modalDealImg").attr("src", deal.image);
$('#modalDealDescription').html(deal.description);
//Normal
currentDealSelectedPrice = deal.priceNotFormated;
// $('#variants-area').hide();
$('.quantity-area').show();
$('#dealModal').modal('show');
}
<?php
$deals =[];
foreach ($deals as $deal){
$theArray = [
'name' => $deal->name,
'id' => $deal->id,
'priceNotFormated' => $deal->price,
'price' => #money($deal->price, env('CASHIER_CURRENCY', 'usd'), true) . '',
'image' => $deal->logom,
'description' => $deal->description,
];
echo 'deals[' . $deal->id . ']=' . json_encode($theArray) . ';';
}
?>
<script>
$(document).ready(function() {
$("#addToCart1").show();
// $('#exrtas-area').show();
$('.quantity-area').show();
});
</script>
#endsection
modals.blade.php
<div class="modal fade" id="dealModal" z-index="9999" tabindex="-1" role="dialog" aria-labelledby="modal-form" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered modal-" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 id="modalDealTitle" class="modal-title" id="modal-title-new-item"></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body p-0">
<div class="card bg-secondary shadow border-0">
<div class="card-body px-lg-5 py-lg-5">
<div class="row">
<div class="col-sm col-md col-lg col-lg text-center">
<img id="modalDealImg" src="" width="295px" height="200px">
</div>
<div class="col-sm col-md col-lg col-lg">
<input id="modalDealID" type="hidden"></input>
<span id="modalDealPrice" class="new-price"></span>
<p id="modalDealDescription"></p>
</div>
<div class="offset-md-6 col-md-6">
#if(!config('app.isqrsaas'))
<div class="quantity-area">
<div class="form-group">
<br />
<label class="form-control-label" for="quantity">{{ __('Quantity') }}</label>
<input type="number" name="quantity" id="quantity" class="form-control form-control-alternative" placeholder="{{ __('1') }}" value="1" required autofocus>
</div>
<div class="quantity-btn float-right">
<div id="addToCart1">
<button class="btn btn-primary" v-on:click='addToCartAct'
<?php
if(auth()->user()){
if(auth()->user()->hasRole('client')) {echo "";} else {echo "disabled";}
}else if(auth()->guest()) {echo "";}
?>
>{{ __('Add To Cart') }}</button>
</div>
</div>
</div>
#endif
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="productModal" z-index="9999" tabindex="-1" role="dialog" aria-labelledby="modal-form" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered modal-" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 id="modalTitle" class="modal-title" id="modal-title-new-item"></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body p-0">
<div class="card bg-secondary shadow border-0">
<div class="card-body px-lg-5 py-lg-5">
<div class="row">
<div class="col-sm col-md col-lg col-lg text-center">
<img id="modalImg" src="" width="295px" height="200px">
</div>
<div class="col-sm col-md col-lg col-lg">
<input id="modalID" type="hidden"></input>
<span id="modalPrice" class="new-price"></span>
<p id="modalDescription"></p>
<div id="variants-area">
<label class="form-control-label">{{ __('Select your options') }}</label>
<div id="variants-area-inside">
</div>
</div>
</div>
<div class="col-md-12">
<div id="exrtas-area">
<br />
<label class="form-control-label h4" for="quantity">{{ __('Extras') }}</label>
<div class="row" id="exrtas-area-inside"></div>
</div>
</div>
<div class="offset-md-6 col-md-6">
#if(!config('app.isqrsaas'))
<div class="quantity-area">
<div class="form-group">
<br />
<label class="form-control-label" for="quantity">{{ __('Quantity') }}</label>
<input type="number" name="quantity" id="quantity" class="form-control form-control-alternative" placeholder="{{ __('1') }}" value="1" required autofocus>
</div>
<div class="quantity-btn float-right">
<div id="addToCart1">
<button class="btn btn-primary" v-on:click='addToCartAct'
<?php
if(auth()->user()){
if(auth()->user()->hasRole('client')) {echo "";} else {echo "disabled";}
}else if(auth()->guest()) {echo "";}
?>
>{{ __('Add To Cart') }}</button>
</div>
</div>
</div>
#endif
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

Modal do not want to open - Bootstrap

I want to make my modal apper, but I can not to do it.
This is my code:
<div class="container h-100">
<div class="row justify-content-sm-center h-100">
<div class="col-xxl-4 col-xl-5 col-lg-5 col-md-7 col-sm-9">
<div class="text-center my-5">
<img src="img/logo-branca.png" alt="logo" width="100">
</div>
<div class="card shadow-lg">
<div class="card-body p-5">
<h1 class="fs-4 card-title fw-bold mb-4">CEP</h1>
<form method="POST" action = "autenticar.php">
<div class="mb-3">
<input id="cep" type="number" class="form-control" name="cep" value="" required="required">
</div>
<button type="submit" class="btn btn-primary ms-auto">
Pesquisar
</button>
</div>
</form>
</div>
<div class="card-footer py-3 border-0">
<div class="text-center">
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#staticBackdrop">
BUTTON TO OPEN THE MODAL
</button>
</div>
</div>
</div>
<div class="text-center mt-5 text-muted">
Copyright © 2021 — Rodrigo Franco
</div>
</div>
</div>
</div>
And this my modal:
<div class="modal fade" id="staticBackdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="staticBackdropLabel">Modal title</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Understood</button>
</div>
</div>
</div>
</div>
If you need to see my project compleatly, just go to this link or if you want to make download the project, just go here
You are not loading Bootstrap's javascript files, simply add:
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
To the head of your document and the modal works.
Resources: https://getbootstrap.com/docs/5.0/components/modal/

cannot delete last data on table using laravel destroy function

I create a laravel destroy function and i use a modal to delete data. but i cannot delete all data in my database. last one cannot be deleted. i think it cause in view.
this is my modal popup in view
<div class="modal fade" id="delete-form" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Delete Account</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form id="delete-form" action="{{ route('account.destroy', [$account->id]) }}" method="post">
<input type="hidden" name="_method" value="delete">
{{ csrf_field() }}
<p>Are you sure you want to delete this data? </p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Save changes</button>
</div>
</form>
</div>
</div>
</div>
And my destroy controller
public function destroy(Account $account)
{
$findAccount = Account::find($account->id);
if($findAccount->delete()){
return redirect()->route('account.index')->with('success', 'Account details delete successfully!');
}
return back()->withInput()->with('error', 'Account details could not be deleted.');
}
i cannot delete all data in table. they keep one data and it cannot be deleted.
Try this:
#extends('template.app')
#section('content')
<div class="col-md-9">
<!-- table content -->
<div class="card">
<div class="card-header main-color-bg">
<h3 class="card-title">Account Details</h3>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-12">
<input class="form-control rounded-corner" type="text" placeholder="Search Member Here" style="margin-bottom: 20px;">
</div>
</div>
<!-- success message -->
#include('inc.message')
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Account Number</th>
<th scope="col">Type</th>
<th scope="col">Amount</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
#if(is_empty($accounts))
<tr><td>NO DATA</td></tr>
#else
#foreach($accounts as $account)
<tr>
<th scope="row">{{$account->id}}</th>
<td>{{$account->acc_no}}</td>
<td>{{$account->acc_type}}</td>
<td>{{$account->amount}}</td>
<td><a class="btn btn btn-secondary" href="{{route('account.edit', $account->id)}}"><span class="fa fa-pencil"></span> Edit</a> <a class="btn btn btn-danger"
data-toggle="modal" data-target="#delete-form"><span class="fa fa-trash-o"></span> Delete</a></td>
</tr>
#endforeach
#endif
</tbody>
</table>
<!-- pagination -->
<nav id="pagination">
<ul class="pagination justify-content-center">
<li class="page-item disabled">
<span class="page-link"><span class="fa fa-arrow-circle-left"></span></span>
</li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item active">
<span class="page-link">
2
<span class="sr-only">(current)</span>
</span>
</li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item">
<a class="page-link" href="#"><span class="fa fa-arrow-circle-right"></span></a>
</li>
</ul>
</nav>
<!-- end pagination -->
<button type="button" class="btn btn-success" data-toggle="modal" data-target="#myModal"><span class="fa fa-plus"></span> Add Account</button>
</div>
</div>
<!-- end table content -->
</div>
<!-- delete modal -->
<!-- Modal -->
<div class="modal fade" id="delete-form" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Delete Account</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form id="delete-form" action="{{ route('account.destroy', [$account->id]) }}" method="delete">
<input type="hidden" name="_method" value="delete">
{{ csrf_field() }}
<p>Are you sure you want to delete this data? </p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Save changes</button>
</div>
</form>
</div>
</div>
</div>
<!-- end delete modal-->
<!-- modal popup -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header" style="background-color: #309fe2; color: #fff;">
<h5 class="modal-title" id="exampleModalLabel">Account Details</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
{!! Form::open(['url' => '/account', 'id' => 'eventForm', 'data-toggle' => 'validator', 'role' => 'form']) !!}
{{ csrf_field() }}
<div class="modal-body">
<!-- modal form -->
<div class="form-group">
<label for="acc_no">Account Number</label>
<input type="number" class="form-control" name="acc_no" id="acc_no" maxlength="20" placeholder="Enter your account number" required>
</div>
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" maxlength="30" name="name" id="name" placeholder="Enter your name" required>
</div>
<div class="form-group">
<label for="id_no">Identity No</label>
<input type="number" class="form-control" maxlength="9" name="id_no" id="id_no" placeholder="Enter your identity no" required>
</div>
<div class="form-group">
<label for="bank_id">Bank</label>
<select class="form-control" name="bank_id">
#if(!empty($banks))
#foreach($banks as $bank)
<option value="{{ $bank->id }}">{{ $bank->name }}</option>
#endforeach
#endif
</select>
</div>
<div class="form-group">
<label for="acc_type">Account Type</label>
<select class="form-control" id="acc_type" name="acc_type">
<option value="Saving">Saving</option>
<option value="Current">Current</option>
<option value="Deposite">Deposite</option>
</select>
</div>
<div class="form-group">
<label for="amount">Amount</label>
<input type="text" pattern="[0-9.]" class="form-control" maxlength="15" name="amount" id="amount" placeholder="Enter your amount" required>
</div>
<!-- end modal form -->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal"><span class="fa fa-times-circle"></span> Close</button>
<button type="submit" class="btn btn-primary pull-right"><span class="fa fa-money"></span> Save changes</button>
</div>
{!! Form::close() !!}
</div>
</div>
</div>
<!-- end modal -->
#endsection
On your delete form change method from POST to DELETE.
I think may be Account::find($account->id); did not get the right Account object. use findOrFail to have another shot:
public function destroy(Account $account)
{
$findAccount = Account::findOrFail($account->id);
...
}
this is my table view. where i put if statement
#foreach($accounts as $account)
<tr>
<th scope="row">{{$account->id}}</th>
<td>{{$account->acc_no}}</td>
<td>{{$account->acc_type}}</td>
<td>{{$account->amount}}</td>
<td><a class="btn btn btn-secondary" href="{{route('account.edit', $account->id)}}"><span class="fa fa-pencil"></span> Edit</a> <a class="btn btn btn-danger"
data-toggle="modal" data-target="#delete-form"><span class="fa fa-trash-o"></span> Delete</a></td>
</tr>
#endforeach
#extends('template.app')
#section('content')
<div class="col-md-9">
<!-- table content -->
<div class="card">
<div class="card-header main-color-bg">
<h3 class="card-title">Account Details</h3>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-12">
<input class="form-control rounded-corner" type="text" placeholder="Search Member Here" style="margin-bottom: 20px;">
</div>
</div>
<!-- success message -->
#include('inc.message')
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Account Number</th>
<th scope="col">Type</th>
<th scope="col">Amount</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
#if(!empty($accounts))
#foreach($accounts as $account)
<tr>
<th scope="row">{{$account->id}}</th>
<td>{{$account->acc_no}}</td>
<td>{{$account->acc_type}}</td>
<td>{{$account->amount}}</td>
<td><a class="btn btn btn-secondary" href="{{route('account.edit', $account->id)}}"><span class="fa fa-pencil"></span> Edit</a> <a class="btn btn btn-danger"
data-toggle="modal" data-target="#delete-form"><span class="fa fa-trash-o"></span> Delete</a></td>
</tr>
#endforeach
#endif
</tbody>
</table>
<!-- pagination -->
<nav id="pagination">
<ul class="pagination justify-content-center">
<li class="page-item disabled">
<span class="page-link"><span class="fa fa-arrow-circle-left"></span></span>
</li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item active">
<span class="page-link">
2
<span class="sr-only">(current)</span>
</span>
</li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item">
<a class="page-link" href="#"><span class="fa fa-arrow-circle-right"></span></a>
</li>
</ul>
</nav>
<!-- end pagination -->
<button type="button" class="btn btn-success" data-toggle="modal" data-target="#myModal"><span class="fa fa-plus"></span> Add Account</button>
</div>
</div>
<!-- end table content -->
</div>
<!-- delete modal -->
<!-- Modal -->
<div class="modal fade" id="delete-form" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Delete Account</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form id="delete-form" action="{{ route('account.destroy', [$account->id]) }}" method="delete">
<input type="hidden" name="_method" value="delete">
{{ csrf_field() }}
<p>Are you sure you want to delete this data? </p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Save changes</button>
</div>
</form>
</div>
</div>
</div>
<!-- end delete modal-->
<!-- modal popup -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header" style="background-color: #309fe2; color: #fff;">
<h5 class="modal-title" id="exampleModalLabel">Account Details</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
{!! Form::open(['url' => '/account', 'id' => 'eventForm', 'data-toggle' => 'validator', 'role' => 'form']) !!}
{{ csrf_field() }}
<div class="modal-body">
<!-- modal form -->
<div class="form-group">
<label for="acc_no">Account Number</label>
<input type="number" class="form-control" name="acc_no" id="acc_no" maxlength="20" placeholder="Enter your account number" required>
</div>
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" maxlength="30" name="name" id="name" placeholder="Enter your name" required>
</div>
<div class="form-group">
<label for="id_no">Identity No</label>
<input type="number" class="form-control" maxlength="9" name="id_no" id="id_no" placeholder="Enter your identity no" required>
</div>
<div class="form-group">
<label for="bank_id">Bank</label>
<select class="form-control" name="bank_id">
#if(!empty($banks))
#foreach($banks as $bank)
<option value="{{ $bank->id }}">{{ $bank->name }}</option>
#endforeach
#endif
</select>
</div>
<div class="form-group">
<label for="acc_type">Account Type</label>
<select class="form-control" id="acc_type" name="acc_type">
<option value="Saving">Saving</option>
<option value="Current">Current</option>
<option value="Deposite">Deposite</option>
</select>
</div>
<div class="form-group">
<label for="amount">Amount</label>
<input type="text" pattern="[0-9.]" class="form-control" maxlength="15" name="amount" id="amount" placeholder="Enter your amount" required>
</div>
<!-- end modal form -->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal"><span class="fa fa-times-circle"></span> Close</button>
<button type="submit" class="btn btn-primary pull-right"><span class="fa fa-money"></span> Save changes</button>
</div>
{!! Form::close() !!}
</div>
</div>
</div>
<!-- end modal -->
#endsection

My Php Script Exception message: count(): Parameter must be an array or an object that implements Countable

"count(): Parameter must be an array or an object that implements
Countable (View:
D:\xampp\htdocs\btrade\core\resources\views\dashboard\user-details.blade.php)"
Looking for I saw that some have this error in their code, but I did not find how can i solve my problem please help me
i think This is the failing case:
#if(count($user))
My php version : PHP 7.2.0
this my error imge
this is my code
#extends('layouts.dashboard')
#section('style')
<link href="{{ asset('assets/admin/css/bootstrap-toggle.min.css') }}" rel="stylesheet">
#endsection
#section('content')
#if(count($user))
<div class="row">
<div class="col-md-12">
<div class="portlet blue box">
<div class="portlet-title">
<div class="caption font-dark">
<strong>User Details</strong>
</div>
<div class="tools"> </div>
</div>
<div class="portlet-body" style="overflow:hidden;">
<div class="col-md-3">
<div class="portlet box blue">
<div class="portlet-title">
<div class="caption uppercase bold">
<i class="fa fa-user"></i> PROFILE </div>
</div>
<div class="portlet-body text-center" style="overflow:hidden;">
<img src="#if($user->image == 'user-default.png') {{ asset('assets/images/user-default.png') }} #else {{ asset('assets/images') }}/{{ $user->image }}#endif" class="img-responsive propic" alt="Profile Pic">
<hr><h4 class="bold">User Name : {{ $user->username}}</h4>
<h4 class="bold">Name : {{ $user->name }}</h4>
<h4 class="bold">BALANCE : {{ $user->balance }} {{ $basic->currency }}</h4>
<hr>
#if($user->login_time != null)
<p>
<strong>Last Login : {{ \Carbon\Carbon::parse($user->login_time)->diffForHumans() }}</strong> <br>
</p>
<hr>
#endif
#if($last_login != null)
<p>
<strong>Last Login From</strong> <br> {{ $last_login->user_ip }} - {{ $last_login->location }} <br> Using {{ $last_login->details }} <br>
</p>
#endif
</div>
</div>
</div>
<div class="col-md-9">
<div class="row">
<div class="col-md-12">
<div class="portlet box purple">
<div class="portlet-title">
<div class="caption uppercase bold">
<i class="fa fa-desktop"></i> Details </div>
<div class="tools"> </div>
</div>
<div class="portlet-body">
<div class="row">
<!-- START -->
<a href="{{ route('user-repeat-all',$user->username) }}">
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12" style="margin-bottom: 20px;">
<div class="dashboard-stat blue">
<div class="visual">
<i class="fa fa-recycle"></i>
</div>
<div class="details">
<div class="number">
<span data-counter="counterup" data-value="{{ $total_repeat }}">0</span>
</div>
<div class="desc uppercase bold"> REPEAT </div>
</div>
<div class="more">
<div class="desc uppercase bold text-center">
{{ $basic->symbol }}
<span data-counter="counterup" data-value="{{ $total_repeat_amount }}">0</span> REPEAT
</div>
</div>
</div>
</div>
</a>
<!-- END -->
<a href="{{ route('user-deposit-all',$user->username) }}">
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12" style="margin-bottom: 20px;">
<div class="dashboard-stat green">
<div class="visual">
<i class="fa fa-cloud-download"></i>
</div>
<div class="details">
<div class="number">
<span data-counter="counterup" data-value="{{ $total_deposit }}">0</span>
</div>
<div class="desc uppercase bold "> DEPOSIT </div>
</div>
<div class="more">
<div class="desc uppercase bold text-center">
{{ $basic->symbol }}
<span data-counter="counterup" data-value="{{ $total_deposit_amount }}">0</span> DEPOSIT
</div>
</div>
</div>
</div>
</a>
<!-- END -->
<a href="{{ route('user-withdraw-all',$user->username) }}">
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12" style="margin-bottom: 20px;">
<div class="dashboard-stat red">
<div class="visual">
<i class="fa fa-cloud-upload"></i>
</div>
<div class="details">
<div class="number">
<span data-counter="counterup" data-value="{{ $total_withdraw }}">0</span>
</div>
<div class="desc uppercase bold "> WITHDRAW </div>
</div>
<div class="more">
<div class="desc uppercase bold text-center">
{{ $basic->symbol }}
<span data-counter="counterup" data-value="{{ $total_withdraw_amount }}">0</span> WITHDRAW
</div>
</div>
</div>
</div>
</a>
<!-- END -->
<a href="{{ route('user-login-all',$user->username) }}">
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12" style="margin-bottom: 20px;">
<div class="dashboard-stat yellow">
<div class="visual">
<i class="fa fa-sign-in"></i>
</div>
<div class="details">
<div class="number">
<span data-counter="counterup" data-value="{{ $total_login }}">0</span>
</div>
<div class="desc uppercase bold "> Log In </div>
</div>
<div class="more">
<div class="desc uppercase bold text-center">
VIEW DETAILS
</div>
</div>
</div>
</div>
</a>
<!-- END -->
</div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="portlet box blue-ebonyclay">
<div class="portlet-title">
<div class="caption uppercase bold">
<i class="fa fa-cogs"></i> Operations </div>
</div>
<div class="portlet-body">
<div class="row">
<div class="col-md-6 uppercase">
<i class="fa fa-money"></i> add / substruct balance
</div>
<div class="col-md-6 uppercase">
<i class="fa fa-envelope-open"></i> Send Email
</div>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="portlet box green">
<div class="portlet-title">
<div class="caption uppercase bold">
<i class="fa fa-cog"></i> Update Profile </div>
</div>
<div class="portlet-body">
<form action="{{ route('user-details-update') }}" method="post">
{!! csrf_field() !!}
<input type="hidden" name="user_id" value="{{ $user->id }}">
<div class="row uppercase">
<div class="col-md-4">
<div class="form-group">
<label class="col-md-12"><strong>Name</strong></label>
<div class="col-md-12">
<input class="form-control input-lg" name="name" value="{{ $user->name }}" type="text">
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="col-md-12"><strong>Email</strong></label>
<div class="col-md-12">
<input class="form-control input-lg" name="email" value="{{ $user->email }}" type="text">
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="col-md-12"><strong>Phone</strong></label>
<div class="col-md-12">
<input class="form-control input-lg" name="phone" value="{{ $user->phone }}" type="text">
</div>
</div>
</div>
</div><!-- row -->
<br><br>
<div class="row uppercase">
<div class="col-md-4">
<div class="form-group">
<label class="col-md-12"><strong>STATUS</strong></label>
<div class="col-md-12">
<input data-toggle="toggle" {{ $user->status == 0 ? 'checked' : ''}} data-onstyle="success" data-size="large" data-offstyle="danger" data-on="Active" data-off="Blocked" data-width="100%" type="checkbox" name="status">
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="col-md-12"><strong>EMAIL VERIFICATION</strong></label>
<div class="col-md-12">
<input data-toggle="toggle" {{ $user->email_verify == 1 ? 'checked' : ''}} data-onstyle="success" data-size="large" data-offstyle="danger" data-on="Verified" data-off="Not Verified" data-width="100%" type="checkbox" name="email_verify">
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="col-md-12"><strong>PHONE VERIFICATION</strong></label>
<div class="col-md-12">
<input data-toggle="toggle" {{ $user->phone_verify == 1 ? 'checked' : ''}} data-onstyle="success" data-size="large" data-offstyle="danger" data-on="Verified" data-off="Not Verified" data-width="100%" type="checkbox" name="phone_verify">
</div>
</div>
</div>
</div><!-- row -->
<br><br>
<div class="row">
<div class="col-md-12">
<button type="submit" class="btn blue btn-block btn-lg">UPDATE</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div><!-- col-9 -->
</div>
</div>
</div>
</div><!-- ROW-->
#else
<div class="text-center">
<h3>No User Found</h3>
</div>
#endif
#endsection
#section('scripts')
<script src="{{ asset('assets/admin/js/bootstrap-toggle.min.js') }}"></script>
<script src="{{ asset('assets/admin/js/jquery.waypoints.min.js') }}" type="text/javascript"></script>
<script src="{{ asset('assets/admin/js/jquery.counterup.min.js') }}" type="text/javascript"></script>
#endsection
The $user variable isn't an array. If that variable must not be an array remove the count function from if statement.
In php5, php7.0, php7.1 it works, but in php7.2 does not work.
#if($user)...
for laravel use below code in web.php
if (version_compare(PHP_VERSION, '7.2.0', '>=')) {
// Ignores notices and reports all other kinds... and warnings
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
// error_reporting(E_ALL ^ E_WARNING); // Maybe this is enough
}
PHP had changed function count() in version 7.2.
In PHP 7.3 will add is_countable();
You can add this function:
function is_countable($var) {
return (is_array($var) || $var instanceof Countable);
}
if (is_countable($user) && count($user)) {
//
}
and remove it in PHP 7.3

How to display a popup when clicks the link in the header?

In my header provide a link for adding new client. When click the add client link display a popup window that contain a textbox and a submit button.When i click the link display popup window fully fade in(shaded) and not display the label
Whats wrong here?
header
<a data-hover="dropdown" data-close-others="true" data-toggle="modal" class="dropdown-toggle" href="#addClientPop" <?php if($home_index== 1) { ?> class="active" <?php } ?>></span>
Add Client<span class="arrow"></span>
</a>
<div id="addClientPop" class="modal hide fade" tabindex="-1" data-width="760">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
<h3>Add Client</h3>
</div>
<div class="modal-body">
<div class="scroller" style="height:75px" data-always-visible="1" data-rail-visible1="1">
<div class="row-fluid">
<div class="control-group">
<label class="control-label">Client Name</label>
<div class="controls">
<input id="client_name" name="client_name" class="client_box" type="text" class="form-control" required >
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button onClick="submit_client();" type="button" class="btn blue">Submit</button>
</div>
</div>
This is your solution i have worked well
<a data-hover="dropdown" data-close-others="true" data-toggle="modal" class="dropdown-toggle active" href="#addClientPop" >
Add Client<span class="arrow"></span>
</a>
<div id="addClientPop" class="modal fade" tabindex="-1" aria-hidden="true">
<div class="modal-dialog ">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
<h3>Add Client</h3>
</div>
<div class="modal-body">
<div class="scroller" style="height:75px" data-always-visible="1" data-rail-visible1="1">
<div class="row-fluid">
<div class="control-group">
<label class="control-label">Client Name</label>
<div class="controls">
<input id="client_name" name="client_name" class="client_box" type="text" class="form-control" required >
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button onClick="submit_client();" type="button" class="btn blue">Submit</button>
</div>
</div>
</div>
</div>
In your code what i have noticed that you have closed </span> tag in <a> and if($home_index==1) then class attribute is going to be add two times.
It should be like:
<a data-hover="dropdown" data-close-others="true" data-toggle="modal" class="dropdown-toggle <?php if($home_index== 1) { echo 'active';}?>" href="#addClientPop">Add Client <span class="fa fa-arrow-down"></span> </a>
<li>
<a data-hover="dropdown" data-close-others="true" data-toggle="modal" class="dropdown-toggle active" href="#addPop" >
Add Client<span class="arrow"></span>
</a>
<div id="addPop" class="modal fade" tabindex="-1" aria-hidden="true">
<div class="modal-dialog ">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
<h3>Add Client</h3>
</div>
<div class="modal-body">
<div class="scroller" style="height:75px" data-always-visible="1" data-rail-visible1="1">
<div class="row-fluid">
<div class="control-group">
<label class="control-label">Client Name</label>
<div class="controls">
<input id="market_price" name="market_price" class="client_box" type="text" class="form-control" required >
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button onClick="submit_price();" type="button" class="btn blue">Submit</button>
</div>
</div>
</div>
</div>
</li>

Categories