"Undefined property: Larapack\DoctrineSupport\Connections\MySqlConnection::$id" - laravel-5.7

I have created search box,I want to search location .I don't know why its giving error on id ,please help me out
controller.php
public function index()
{
$states = HOStateMaster::getAllState();
return view('vendor/voyager/Ho/index')->with('states',$states);
}
public function search(Request $request){
$search = $request->get('search');
$states = DB::table('state_city_master')->where('location','like','%'.$search.'%');
return view('vendor/voyager/Ho/index')->with('states',$states);
}
blade.php
<div class="search-container">
<form method="GET" action="{{ route('state-master.search') }}">
<div style="display:inline-flex"><input type="text" name="search" class="form-control"><button type="submit" class="btn btn-primary"><i class="fa fa-search"></i></button></div>
</form>
</div>
</div>
<div class="card" >
<div class="card-body">
<table class="table striped" style="overflow-x:auto!important;">
<thead class="" style="background-color:black;">
<tr>
<th scope="col">{{ "Id" }}</th>
<th scope="col">{{ "Location" }}</th>
<th scope="col">{{ "Posted Date" }}</th>
<th scope="col">{{ "Action" }}</th>
</tr>
</thead>
<tbody>
#foreach($states as $key => $state)
<tr class="#cbdms_details.IsOdd("odd","even")>
<th scope="row">{{ $state->id }}</th>
<td>{{ $state->location }}</td>
<td>{{ date('Y-m-d',strtotime($state->created_at)) }}</td>
<td>
Error Screenshot

You are forgot ->get()
public function search(Request $request){
$search = $request->get('search');
$states = DB::table('state_city_master')->where('location','like','%'.$search.'%')->get();
return view('vendor/voyager/Ho/index')->with('states',$states);
}

Related

Align a table in Razor

I have a table in my view and the values are not aligned. The first row is perfectly aligned, however the others are not. It seems like they are moving to right after each interaction.
Table's image
This is the view's code:
#model Dictionary<Especializacao, List<Consulta>>
#{
ViewData["Title"] = "Busca Agrupada";
DateTime minDate = DateTime.Parse(ViewData["minDate"] as string);
DateTime maxDate = DateTime.Parse(ViewData["maxDate"] as string);
}
<h1>#ViewData["Title"]</h1>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<div class="form-group">
<label for="minDate">Min Date</label>
<input type="date" class="form-control" name="minDate" value=#ViewData["minDate"]>
</div>
<div class="form-group">
<label for="maxDate">Max Date</label>
<input type="date" class="form-control" name="maxDate" value=#ViewData["maxDate"]>
</div>
</div>
<button type="submit" class="btn btn-primary">Pesquisar</button>
</form>
</div>
</nav>
#foreach (var especialGroup in Model)
{
<div class="panel panel-primary">
<div class="panel-heading bg-primary">
<h3 class="panel-title">Especialização: #especialGroup.Key.Nome, Total: #especialGroup.Key.TotalDeConsultas(minDate, maxDate)</h3>
</div>
<div class="panel-body">
<table class="table table-striped table-hover">
<thead>
<tr class="success">
<th>
Data
</th>
<th>
Valor
</th>
<th>
Doutor
</th>
</tr>
</thead>
<tbody>
#foreach (var item in especialGroup.Value)
{
<tr>
<td>
#Html.DisplayFor(modelItem => item.Data)
</td>
<td>
#Html.DisplayFor(modelItem => item.Valor)
</td>
<td>
#Html.DisplayFor(modelItem => item.Doutor.Nome)
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
}
I don't know what I'm doing wrong. Everything seems to be ok with the code.
I could solve it by applying those lines:
<thead>
<tr class="success">
<th class="col-lg-2">
Data
</th>
<th class="col-lg-2">
Valor
</th>
<th class="col-lg-2">
Doutor
</th>
</tr>
</thead>
<tbody>
#foreach (var item in especialGroup.Value)
{
<tr>
<td class="col-lg-2">
#Html.DisplayFor(modelItem => item.Data)
</td>
<td class="col-lg-2">
#Html.DisplayFor(modelItem => item.Valor)
</td>
<td class="col-lg-2">
#Html.DisplayFor(modelItem =>item.Doutor.Nome)
</td>
</tr>
}
</tbody>

Change css class on #click event of a table responsive table

I would love to change the background color on a row in a table when i click on the tr.
That's the code of the table:
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th><small class="text-muted">#</small></th>
<th>Name</th>
<th>Heading</th>
<th>Productor</th>
</tr>
</thead>
<tbody>
<tr
v-for="company in allCompanies"
:key="company.id"
role="button"
#click="selectCompany(company)"
>
<td class="text-primary">
<small>#{{ company.id }}</small>
</td>
<td class="fw-bold">{{ company.name }}</td>
<td>{{ company.heading }}</td>
<td>
{{ company.productor }}
</td>
</tr>
</tbody>
</table>
</div>
And here the code of the method I call on the click event:
selectCompany(company) {
this.storeSelectedCompamy(company);
this.fetchShows(company.id);
console.log("change css");
}
Any help would be appreciated.
Thank you in advance
Valerio
Have a look here:
https://v2.vuejs.org/v2/guide/class-and-style.html
It looks like each <tr> corresponds to a company, so my approach would be to attach each row's state to its corresponding company as a property, and then toggle that property in selectCompany. Something like:
selectCompany(company) {
allCompanies.forEach(_company => _company.isSelected = false);
company.isSelected = true;
}
<tr
v-for="company in allCompanies"
:key="company.id"
:class="company.isSelected ? 'selected' : ''"
role="button"
#click="selectCompany(company)"
>

ASP.NET MVC 5 form doesn't send table rows details(with jQuery datatables 1.10.15)

I created view with form that included table with rows that initialize from list, the table designed with jQuery.datatables 1.10.15.
When I tried to send the form then the table not send, I get null in the list parameter in the action controller.
View page:
#model List<SendMails.ViewModels.ViewModelDetailsFile>
#{
ViewBag.Title = "UpdateItems";
}
#using (Html.BeginForm("UpdateItems", "Home", FormMethod.Post)) {
#Html.AntiForgeryToken()
<table id="DetailsExcelChoose">
<thead>
<tr>
<th class="RightToLeft wideIndexCol">IndexRow</th>
<th class="RightToLeft">InvoiceNumber</th>
<th class="RightToLeft wideIndexCol">NumberClient</th>
<th class="RightToLeft ">NameClient</th>
<th class="RightToLeft wideIndexCol">Amount</th>
<th class="RightToLeft wideIndexCol">Email</th>
<th class="RightToLeft wideIndexCol">ContactPerson</th>
<th class="RightToLeft ">Details</th>
</tr>
</thead>
<tbody name="iObjsUpdate">
#if (Model != null)
{
for (var i = 0; i < Model.Count(); i++)
{
<tr>
<td name="IndexRow">#Model[i].IndexRow</td>
<td name="InvoiceNumber">#Model[i].InvoiceNumber</td>
<td name="NumberClient">#Model[i].NumberClient</td>
<td name="NameClient">#Model[i].NameClient</td>
<td name="Amount">#Model[i].Amount</td>
<td name="Email"><input type="email" id="Email" name="Email" value=#Model[i].Email /></td>
<td name="ContactPerson"><input type="text" id="ContactPerson" name="ContactPerson" value=#Model[i].ContactPerson></td>
<td name="Details">#Model[i].Details</td>
</tr>
}
}
</tbody>
</table>
<div class="form-group row">
<button type="submit" class="btn btn-primary">send</button>
</div>
}
JS file:
$(document).ready(function () {
var dataTable = $("#DetailsExcelChoose").DataTable();
});
Controller action:
[HttpPost]
[ValidateAntiForgeryToken]
[Route("UpdateItems")]
public async Task<ActionResult> UpdateItems(List<ViewModelDetailsFile> iObjsUpdate)
{
/// iObjsUpdate is null
}
I read that need to set the name attribute for the asp.net know what the columns are...
But all my searching in google not success.
If I didn't clear what I want so... I want to send the rows details to controller action as list of object (yes I know that I can do this in ajax but I want in this way)
For send or post row details to controller you have to use hidden fields on .cshtml or view page.
try this
for (var i = 0; i < Model.Count(); i++)
{
<tr>
#Html.HiddenFor(x => x.Model[i].IndexRow)
#Html.HiddenFor(x => x.Model[i].InvoiceNumber)
#Html.HiddenFor(x => x.Model[i].NumberClient)
#Html.HiddenFor(x => x.Model[i].NameClient)
#Html.HiddenFor(x => x.Model[i].Amount)
#Html.HiddenFor(x => x.Model[i].Email )
#Html.HiddenFor(x => x.Model[i].ContactPerson)
#Html.HiddenFor(x => x.Model[i].Details)
<td name="IndexRow">#Model[i].IndexRow</td>
<td name="InvoiceNumber">#Model[i].InvoiceNumber</td>
<td name="NumberClient">#Model[i].NumberClient</td>
<td name="NameClient">#Model[i].NameClient</td>
<td name="Amount">#Model[i].Amount</td>
<td name="Email"><input type="email" id="Email" name="Email" value=#Model[i].Email /></td>
<td name="ContactPerson"><input type="text" id="ContactPerson" name="ContactPerson" value=#Model[i].ContactPerson></td>
<td name="Details">#Model[i].Details</td>
</tr>
}

Stored Procedure Error-'Procedure or function 'requisition_sp_setstatus0' expects parameter '#ReqNumber', which was not supplied

When I click on the approve I'm getting this error : 'Procedure or function 'requisition_sp_setstatus0' expects parameter '#ReqNumber', which was not supplied.' once I remove this code of lines
#*<tr>
<td>#Html.CheckBoxFor(m => m[i].postTrnx, new { #class = "checkGroup1" })</td>
<td class="label">
#Html.DisplayFor(m => m[i].reqNumber)
#Html.DisplayFor(m => m[i].reqDate)
</td>
</tr>
but I don't want to be in that format but showcase in the table. Why isn't the function picking up the requisition number from the table but picking it up from display. I have to select the display part inorder for it to be approve.
public void SetRequisitionStatus0(List<string> docNumbers)
{
SqlConnection connection = new SqlConnection(connectionString);
SqlCommand command = new SqlCommand();
command.CommandText = "requisition_sp_setstatus0";
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("#ReqNumber", SqlDbType.VarChar);
command.Parameters.Add("#approve_date", SqlDbType.DateTime).Value = DateTime.Now;
using (command.Connection = connection)
{
try
{
connection.Open();
foreach (var item in docNumbers)
{
command.Parameters["#ReqNumber"].Value = item;
command.ExecuteNonQuery();
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
connection.Close();
}
}
return;
}
#using (Html.BeginForm())
{
#Html.AntiForgeryToken()
<div>
<hr />
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
#*<input type="submit" value="Issue" name="Issue" class="btn btn-default" />*#
#*<input type="submit" value="Search" name="Search" class="btn btn-default" />*#
</div>
</div>
<table id="data">
<thead>
<tr>
<th class="col-lg-1">#Html.CheckBox("TheOneCheckBoxToRuleThemAll")Select All</th>
<th class="col-lg-1 ">Date</th>
<th class="col-lg-1 ">Requisition Number</th>
<th class="col-lg-1 ">Expense Account</th>
<th class="col-lg-1">Requestor</th>
<th class="col-lg-1">Department</th>
<th class="col-lg-1">LoggedinAs</th>
<th class="col-lg-1 ">Item Number</th>
<th class="col-lg-1 ">Description</th>
<th class="col-sm-1">Quantity</th>
<th class="col-sm-1 ">UOM</th>
</tr>
<tbody>
#for (int i = 0; i < Model.Count; i++)
{
#Html.HiddenFor(m => m[i].reqNumber)
#Html.HiddenFor(m => m[i].department)
#Html.HiddenFor(m => m[i].department)
#*<tr>
<td>#Html.CheckBoxFor(m => m[i].postTrnx, new { #class = "checkGroup1" })</td>
<td class="label">
#Html.DisplayFor(m => m[i].reqNumber)
#Html.DisplayFor(m => m[i].reqDate)
</td>
</tr>*#
foreach (var item in Model[i].items)
{
#Html.HiddenFor(m => item.description)
#Html.HiddenFor(m => item.expense_account)
#Html.HiddenFor(m => item.itemNumber)
<tr>
<td>#Html.CheckBoxFor(m => m[i].postTrnx, new { #class = "checkGroup1" })</td>
<td class="col-lg-1 tabledata" >#item.requisition.reqDate</td>
<td class="col-lg-1 tabledata" >#item.requisition.reqNumber</td>
<td class="col-lg-1 tabledata">#item.expense_account.account_desc</td>
<td class="col-lg-1 tabledata">#item.employeeDetails.employeeNum</td>
<td class="col-lg-1 tabledata">#item.employeeDetails.department</td>
<td class="col-lg-1 tabledata">#item.employeeDetails.LoggedInUserName</td>
<td class="col-lg-1 tabledata">#item.itemNumber</td>
<td class="col-lg-1 tabledata">#item.description</td>
<td class="col-sm-1 tabledata">#item.quantity</td>
<td class="col-sm-1 tabledata">#item.selecteduomtext </td>
#*<td>#Html.ActionLink("Edit", "Edit", new { id = #item.lineNum, name = Model[i].reqNumber })</td>*#
</tr>
}
}
</tbody>
</table>
<br /><br /><br />
<div>
<input type="submit" value="Approve" name="Approve" class="btn btn-default" onclick="return confirm('Click OK to continue or Cancel to abort');" />
</div>
}

on bootstrap table column expand strangely

I have a table and ,in the note column , i should add long note that area. When i add very long note, the line expand but i just want to note settle new lines.
Example :
asyufgasdfhjdasfghfghasfhaahjfsghjahfjqjwjefqfeqwhkfwq
I want this :
jdsaaafjasasjs
ywewyuwqfyuyew
quyduquyqewfyy
And my table's code : (I want to fix td with 'thisone' id)
<div class="col-md-6">
<div class="content-box-large">
<div class="panel-heading">
<div class="panel-title">Notlar</div>
<div class="panel-options">
<i class="glyphicon glyphicon-refresh"></i>
<i class="glyphicon glyphicon-cog"></i>
</div>
</div>
<div class="panel-body">
<table class="table table-striped">
<?php if(mysqli_num_rows($listele)>0)
{ ?>
<thead>
<tr>
<th>Tarih</th>
<th>Saat</th>
<th>Dosya Notu</th>
<th>Notu Kaydeden Kişi</th>
</tr>
</thead>
<tbody>
<?php
$i=1;
while($not=mysqli_fetch_array($listele))
{
$tarih=$not["tarih"];
?>
<tr>
<td><?php echo date("d/m/Y",strtotime($tarih)); ?></td>
<td><?php echo date("H:i",strtotime($tarih)); ?></td>
<td id="thisone"><?php echo $not["dosya_not"]; ?></td>
<td><?php echo $not["calisan_adi"]; ?></td>
</tr>
<?php
$i++;
}
}?>
</tbody>
</table>
</div>
<div class="panel-body">
<table class="table table-striped">
<tr>
<td><input type="hidden" id="musteri_id" value="<?php echo $musteri_id; ?>"></td>
<td id="not"><textarea class="form-control" id="not_degeri" placeholder="Notu Giriniz" rows="3"></textarea></td>
<td id="buton"><button class="btn btn-primary" id="ekle">Yeni Not Ekle</button></td>
</tr>
</tbody>
</table>
</div>
</div>
</di
v>
You can use word breaking option in CSS
td {
word-break: break-all;
}
<style>
td { word-break: break-all; }
</style>
<div class="col-md-6">
<div class="content-box-large">
<div class="panel-heading">
<div class="panel-title">Notlar</div>
<div class="panel-options">
<i class="glyphicon glyphicon-refresh"></i>
<i class="glyphicon glyphicon-cog"></i>
</div>
</div>
<div class="panel-body">
<table class="table table-striped">
<thead>
<tr>
<th>Tarih</th>
<th>Saat</th>
<th>Dosya Notu</th>
<th>Notu Kaydeden Kişi</th>
</tr>
</thead>
<tbody>
<tr>
<td>sometext</td>
<td>some text</td>
<td id="thisone">lsdfjasdklfjasldajklsdfjkldfjklafsjklasdfjlkasdfjklafjklasdfjhklasdfjhklasdfjhklasdfajklasdfjklasdfjkl</td>
<td>some text</td>
</tr>
</tbody>
</table>
</div>
<div class="panel-body">
<table class="table table-striped">
<tr>
<td><input type="hidden" id="musteri_id" value=""></td>
<td id="not"><textarea class="form-control" id="not_degeri" placeholder="Notu Giriniz" rows="3"></textarea></td>
<td id="buton"><button class="btn btn-primary" id="ekle">Yeni Not Ekle</button></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>

Resources