I want to search and display specific data from db and the method that I have made is not retrieving data from database, if i print it just gives a empty array.
My code is as follow:
Controller:
public function search() {
$search = Input::get('search');
if($search){
$query = DB::table('volunteer');
$results = $query ->where('bloodt', 'LIKE', $search) ->get();
//print_r($results); exit;
return View::make('search')->with("volunteer",$results);
}
}
View:
{{Form::open(array('method'=>'POST'))}}
<div class="pull-left col-xs-6 col-xs-offset-0">
{{Form::text('search','',array('placeholder'=>'Search by blood type/zip code/address....','class'=>'form-control','required autofocus'))}}
</div>
<input type="submit" name="search" value="Search" class="btn btn-primary">
<br><br>
{{Form::close()}}
<?php if (isset($results)) { ?>
#foreach($volunteer as $results)
<table class="table table-bordered" style="width: 100%; background-color: lightsteelblue">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>IC/Passport no.</th>
<th>Blood Type</th>
<th>Address</th>
<th>Zip Code</th>
<th>e-mail</th>
<th>Phone no.</th>
<th>Status</th>
</tr>
<tr>
<td>{{ $results->fname }}</td>
<td>{{ $results->lname }}</td>
<td>{{ $results->ic }}</td>
<td>{{ $results->bloodt }}</td>
<td>{{ $results->address }}</td>
<td>{{ $results->zipcode }}</td>
<td>{{ $results->email }}</td>
<td>{{ $results->phone }}</td>
<td>
<div class="btn-group" role="group">
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">
{{ $results->status }}
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>Eligible</li>
<li>Not Eligible</li>
</ul>
</div>
</td>
</tr>
</table>
#endforeach
<?php;
} ?>
Route:
Route::post('search', 'HomeController#search');
Related
I have a modal pop out when pressing a button. Problem is, how do pass the value to the modal?
My table as shown in figure below. As you can see each row have different id. I wanted to get the id of a particular row after pressed the button.
The problem is how to display data in to bootstrap modal according to id. Thanks in advance.
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>ردیف</th>
<th>مقطع تحصیلی</th>
<th>رشته تحصیلی</th>
<th>تاریخ اخذ مدرک</th>
<th>جزییات بیشتر</th>
</tr>
</thead>
<tbody>
#foreach($user->educationals as $educational)
<tr>
<td class="fw-normal">{{ $educational->id }}</td>
<td class="fw-normal">{{ $educational->grade }}</td>
<td class="fw-normal">{{ $educational->major }}</td>
<td class="fw-normal">{{ $educational->end }}</td>
<td><a class="btn btn-link" data-bs-toggle="modal" data-bs-target="#educationals{{ $educational->id }}">جزییات بیشتر</a></td>
</tr>
#endforeach
</tbody>
</table>
</div>
#if(isset($educational))
<div class="modal fade" id="educationals{{ $educational->id }}" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="educationals{{ $educational->id }}" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="educationals{{ $educational->id }}">درخواست</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<table class="table">
<tr>
<th>مقطع تحصیلی</th>
<td>{{ $educational->grade }}</td>
</tr>
<tr>
<th>رشته تحصيلي</th>
<td>{{ $educational->major }}</td>
</tr>
<tr>
<th>معدل</th>
<td>{{ $educational->avg }}</td>
</tr>
<tr>
<th>تاريخ شروع</th>
<td>{{ $educational->start }}</td>
</tr>
<tr>
<th>تاريخ اخذ مدرك</th>
<td>{{ $educational->end }}</td>
</tr>
<tr>
<th>موسسه دريافت اخذ مدرك</th>
<td>{{ $educational->docPlaceName }}</td>
</tr>
<tr>
<th>عنوان پايان نامه / رساله</th>
<td>{{ $educational->thesisTitle }}</td>
</tr>
<tr>
<th>مدارك</th>
<td>{{ $educational->upload_doc }}</td>
</tr>
<tr>
<th>کشور محل دريافت مدرك</th>
<td>{{ $educational->docPlaceCountry }}</td>
</tr>
<tr>
<th>شهر محل دريافت مدرك</th>
<td>{{ $educational->docPlaceCity }}</td>
</tr>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-bs-dismiss="modal">اوکی</button>
</div>
</div>
</div>
</div>
#else
<div class="alert alert-warning text-center" role="alert">
اطلاعاتی وجود ندارد.
</div>
#endif
You have many options but I suggest you to use javascript in any form you prefer. But if you don't want to use javascript, you should make model for each of table rows.
#foreach($user->educationals as $educational)
<div class="modal fade" id="educationals{{ $educational->id }}" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="educationals{{ $educational->id }}" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="educationals{{ $educational->id }}">درخواست</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<table class="table">
<tr>
<th>مقطع تحصیلی</th>
<td>{{ $educational->grade }}</td>
</tr>
<tr>
<th>رشته تحصيلي</th>
<td>{{ $educational->major }}</td>
</tr>
<tr>
<th>معدل</th>
<td>{{ $educational->avg }}</td>
</tr>
<tr>
<th>تاريخ شروع</th>
<td>{{ $educational->start }}</td>
</tr>
<tr>
<th>تاريخ اخذ مدرك</th>
<td>{{ $educational->end }}</td>
</tr>
<tr>
<th>موسسه دريافت اخذ مدرك</th>
<td>{{ $educational->docPlaceName }}</td>
</tr>
<tr>
<th>عنوان پايان نامه / رساله</th>
<td>{{ $educational->thesisTitle }}</td>
</tr>
<tr>
<th>مدارك</th>
<td>{{ $educational->upload_doc }}</td>
</tr>
<tr>
<th>کشور محل دريافت مدرك</th>
<td>{{ $educational->docPlaceCountry }}</td>
</tr>
<tr>
<th>شهر محل دريافت مدرك</th>
<td>{{ $educational->docPlaceCity }}</td>
</tr>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-bs-dismiss="modal">اوکی</button>
</div>
</div>
</div>
</div>
#endforeach
I'm trying to print values in from database in table. However the error shows undefined variable outlets in app.blade.php. I'm a beginner in laravel I've copied the function from index.blade.php where it is working. Any help will be highly appreciative.
App.blade.php:
<div class="col-md-12">
<div class="card">
<div class="card-header">
<form method="GET" action="" accept-charset="UTF-8" class="form-inline">
<input type="submit" value="{{ __('outlet.search') }}" class="btn btn-secondary">
{{ __('app.reset') }}
</form>
</div>
<table class="table table-sm table-responsive-sm">
<thead>
<tr>
<th class="text-center">{{ __('app.table_no') }}</th>
<th>{{ __('outlet.name') }}</th>
<th class="text-center">{{ __('app.action') }}</th>
</tr>
</thead>
<tbody>
#foreach($outlets as $key => $outlet)
<tr>
<td class="text-center">{{ $outlets->firstItem() + $key }}</td>
<td>{!! $outlet->name_link !!}</td>
<td>{{ $outlet->address }}</td>
<td>{{ $outlet->latitude }}</td>
<td>{{ $outlet->longitude }}</td>
<td class="text-center">
{{ __('app.show') }}
</td>
</tr>
#endforeach
</tbody>
</table>
<div class="card-body">{{ $outlets->appends(Request::except('page'))->render() }}</div>
OutletController.php
public function index()
{
$this->authorize('manage_outlet');
$outletQuery = Outlet::query();
$outletQuery->where('name', 'like', '%'.request('q').'%');
$outlets = $outletQuery->paginate(25);
return view('outlets.index', compact('outlets'));
}
public function app()
{
$outlets = "this is outlet";
return view('outlets.app', compact('outlets'));
}
Error:
ErrorException (E_ERROR)
Undefined variable: outlets (View: /home/converse/laravel_leaflet_1/resources/views/layouts/app.blade.php) (View: /home/converse/laravel_leaflet_1/resources/views/layouts/app.blade.php)
I have this code :
<div class="table-responsive">
<table class="table table-condensed table-hover">
<tr>
<th>#</th>
<th>Name</th>
<th>username</th>
<th>Email</th>
<th>Rank</th>
<th>Join</th>
</tr>
#if($count)
#foreach($users as $i => $user)
<tr>
<td>{{ $i+1 }}</td>
<td>{{ $user->first_name }} {{ $user->last_name }}</td>
<td>{{ $user->username }}</td>
<td>{{ $user->email }}</td>
<td>
#if($user->rank == 0)
Admin
#else
User
#endif
</td>
<td>{{ $user->created_at }}</td>
{{ Form::hidden('id', $user->id,['class'=>'id']) }}
{{ Form::hidden('username', $user->username,['class'=>'username']) }}
<td><button id="submit" type="button" class="btn btn-danger" data-toggle="modal" data-target="#deleteModal">
Delete
</button></td>
</tr>
#endforeach
#else
<div class="alert alert-success" style="text-align:center">
There is no users in the Site
</div>
#endif
which used Blade Template engine, but in case that's count is false the alert div appears before Heading of table
How can this problem be fixed ?
I may be missing something here, the code above seems incomplete (table is not closing). But why not move your alert outside of the other if so you can place it where you need it:
#if(!$count)
<div class="alert alert-success" style="text-align:center">
There is no users in the Site
</div>
#endif
[Solution]:Finally i did it by myself. so here is solution it takes (7 hours.)
//Solution angularjs
$scope.exampleArray = [];
$scope.pushInArray = function(id) {
// get the input value
var inputVal = id;
var array = $scope.exampleArray.push(inputVal);
$scope.deleteBulk = function(){
if(confirm("Are you sure you want to delete this record?")){
$http.post('http://localhost/angular-code-crud/index.php/user/bulk_delete_user',
{'id':$scope.exampleArray}).success(function(){
$scope.displayUsers();
});
}
};
};
<!-- Solution HTML -->
<button class="btn btn-danger" ng-click="deleteBulk()" >Delete</button>
<table class="table table-striped">
<thead>
<tr>
<th><input type="checkbox" ng-model="master" ></th>
<th>Name</th>
<th>Gender</th>
<th>Email</th>
<th>Address</th>
<th>Phone</th>
<th>Action</th>
</tr>
</thead>
<tbody>
</tbody>
<tr ng-repeat="user in users | filter:searchUser">
<td><!-- <input type="checkbox" ng-click="deleteBulk(user.id)" ng-true-value="{{user.id}}" ng-checked="master" checklist-model="user.id" checklist-value="{{user.id}}">{{ user.id }} -->
<input type="checkbox" name="arrExample" ng-model="arrInput" ng-true-value="{{user.id}}" ng-checked="master"ng-click='pushInArray(user.id)'><br>
</td>
<td>{{ user.name }}</td>
<td>{{ user.gender }}</td>
<td>{{ user.email }}</td>
<td>{{ user.address }}</td>
<td>{{ user.phone }}</td>
<td>
<button class="btn btn-primary" ng-click="updateData(user.id, user.name, user.gender, user.email, user.address, user.phone)">Edit</button>
<button class="btn btn-danger" ng-click="deleteData(user.id)">Delete</button>
</td>
</tr>
</table>
How can i get ids of selected checkbox using angularjs?
i have a table fetched using angularjs. but dont know how i transfer ids of each row which i checked using checkbox.
$scope.deleteBulk = function($scope){
//what code should i use to get ids of checked row
}
<button ng-click="deleteBulk()">Delete</button>
<table class="table table-striped">
<thead>
<tr>
<th>select</th>
<th>Name</th>
<th>Gender</th>
<th>Email</th>
<th>Address</th>
<th>Phone</th>
<th>Action</th>
</tr>
</thead>
<tbody>
</tbody>
<tr ng-repeat="user in users | filter:searchUser">
<td><input type="checkbox" checklist-model="user.roles(user.id)" checklist-value="user.id">{{ user.id }}</td>
<td>{{ user.name }}</td>
<td>{{ user.gender }}</td>
<td>{{ user.email }}</td>
<td>{{ user.address }}</td>
<td>{{ user.phone }}</td>
<td>
<button class="btn btn-primary" ng-click="updateData(user.id, user.name, user.gender, user.email, user.address, user.phone)">Edit</button>
<button class="btn btn-danger" ng-click="deleteData(user.id)">Delete</button>
</td>
</tr>
</table>
I'm clueless. Sorry for bad English,
//Solution angularjs
$scope.exampleArray = [];
$scope.pushInArray = function(id) {
// get the input value
var inputVal = id;
var array = $scope.exampleArray.push(inputVal);
$scope.deleteBulk = function(){
if(confirm("Are you sure you want to delete this record?")){
$http.post('http://localhost/angular-code-crud/index.php/user/bulk_delete_user',
{'id':$scope.exampleArray}).success(function(){
$scope.displayUsers();
});
}
};
};
<!-- Solution HTML -->
<button class="btn btn-danger" ng-click="deleteBulk()" >Delete</button>
<table class="table table-striped">
<thead>
<tr>
<th><input type="checkbox" ng-model="master" ></th>
<th>Name</th>
<th>Gender</th>
<th>Email</th>
<th>Address</th>
<th>Phone</th>
<th>Action</th>
</tr>
</thead>
<tbody>
</tbody>
<tr ng-repeat="user in users | filter:searchUser">
<td><!-- <input type="checkbox" ng-click="deleteBulk(user.id)" ng-true-value="{{user.id}}" ng-checked="master" checklist-model="user.id" checklist-value="{{user.id}}">{{ user.id }} -->
<input type="checkbox" name="arrExample" ng-model="arrInput" ng-true-value="{{user.id}}" ng-checked="master"ng-click='pushInArray(user.id)'><br>
</td>
<td>{{ user.name }}</td>
<td>{{ user.gender }}</td>
<td>{{ user.email }}</td>
<td>{{ user.address }}</td>
<td>{{ user.phone }}</td>
<td>
<button class="btn btn-primary" ng-click="updateData(user.id, user.name, user.gender, user.email, user.address, user.phone)">Edit</button>
<button class="btn btn-danger" ng-click="deleteData(user.id)">Delete</button>
</td>
</tr>
</table>
I have a table of employee's salary list. I wrap the employee id with an anchor tag to show salary history of each individual employees. The problem is when I print the table the link for individual salary history is also printed under the employee id.
Here is a screen shot print preview:
Blade
<div class="d-section col-md-12">
<table class="table table-striped table-condensed table-bordered">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Position</th>
<th>Start Date</th>
<th>End Date</th>
<th>Worked</th>
<th>Basic</th>
<th>OT Rate</th>
<th>OT Hour</th>
<th>OT Amount</th>
<th>Basic Amount</th>
<th>Total</th>
<th>Signature</th>
<th>Finger</th>
</tr>
</thead>
<tbody>
#foreach($employees as $employee)
<tr>
<td>{{ $employee->eid }}</td>
<td>{{ $employee->name }}</td>
<td>{{ $employee->designation }}</td>
<td>{{ $employee->start }}</td>
<td>{{ $employee->end }}</td>
<td>{{ $employee->worked }}</td>
<td>{{ $employee->basic }}</td>
<td>{{ $employee->ot_rate }}</td>
<td>{{ $employee->ot_hour }}</td>
<td>{{ $employee->ot_amount }}</td>
<td>{{ $employee->basic_amount }}</td>
<td>{{ $employee->ot_amount + $employee->basic_amount }}</td>
<td></td>
<td>
{!! Form::open(['action'=>['SalaryController#destroy',$employee->id],'class'=>'no-print','method'=>'delete','onsubmit'=>'return deleteConfirm()']) !!}
{!! Form::submit('X',['class'=>'element btnn btn-danger']) !!}
<br/>
<span class="glyphicon glyphicon-edit"></span>
<br/>
<span class="glyphicon glyphicon-usd"></span>
{!! Form::close() !!}
</td>
</tr>
#endforeach
</tbody>
</table>
</div>
Why not just create a CSS class for your anchors and hide them using that class?
foo
foo
And in your CSS:
.only-print{
display:none;
}
#media print{
a.hiddenTab {
display:none;
}
.only-print{
display:block;
}
}
All the anchors you'd want to hide would just use class="hiddenTab".
If you want to hide all a tags which have href set, you can do this:
a[href] { display: none; }