Can you post the full contents of the error message - especially the part where it describes where the error occurs?
Aug 24, 2022
15
Level 1
Can't pull data from DB
Hi guys, is it possible please to give this code a look, I'm trying to pull data from DB, but I got no data pulled
my controller:
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Gate;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Symfony\Component\HttpFoundation\Response;
class VouchersAccountingController extends Controller
{
public function index(Request $request)
{
abort_if(Gate::denies('vouchers_accounting_access'), Response::HTTP_FORBIDDEN, '403 Forbidden');
$from = $request->from;
$to = $request->to;
$Reports = DB::table('create_vouchers')->whereNull('create_vouchers.deleted_at')
->select('create_vouchers.id', 'client_name', 'night', 'hotels.hotel_name', 'arrivaldate', 'departuredate', 'total_amount', 'number_of_room', 'payment_mode')
->join('hotels', 'hotels.id', 'create_vouchers.hotel_name_id')
->whereBetween('arrivaldate', [$from, $to])->get();
return view('admin.vouchersAccountings.index', compact('Reports', 'from', 'to'));
}
public function search(Request $request)
{
}
my index.blade.php
@extends('layouts.admin')
@section('content')
<link href="{{ asset('css/arrivaldeparture.css') }}" rel="stylesheet" />
<div class="content">
<div class="row">
<div class="col-md-12 mt-4">
<div class="panel panel-default">
<div class="panel-heading">
{{ trans('cruds.vouchersAccounting.title') }}
</div>
<div class="panel-body">
<div class="card">
<div class="card-header">
<h4 class="Green">Reports</h4>
<form name="search" id="search" method="post" action="{{ route('admin.vouchers-accountings.search') }}">
@csrf
<div class="form-group">
From
<div class='input-group date'>
<input id="date-from" name="from" type='text' class="form-control" value="{{ $from }}">
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
</div>
</div>
<div class="form-group">
To
<div class='input-group date' id='CalendarDateTime'>
<input id="date-to" name="to" type='text' class="form-control" value="{{ $to }} ">
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
</div>
</div>
<button type="submit" class="btn btn-primary">Search</button>
</form>
<div class="card-body">
<table class="table">
<thead>
<tr>
<th>Voucher #</th>
<th>Client</th>
<th>Hotel</th>
<th>Arrival</th>
<th>Departure</th>
<th>Nights</th>
<th>Rooms</th>
<th>Payment Mode</th>
<th>Paid Amount</th>
</tr>
</thead>
<tbody>
@foreach($Reports as $Report)
<tr>
<th> {{$Report->id}} </th>
<th> {{$Report->client_name}} </th>
<th> {{$Report->hotel_name}} </th>
<th> {{$Report->arrivaldate}} </th>
<th> {{$Report->departuredate}} </th>
<th> {{$Report->night}} </th>
<th> {{$Report->number_of_room}}</th>
<th> {{$Report->payment_mode}}</th>
<th> {{$Report->total_amount}}</th>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
my route:
// Voucher Accounting
Route::resource('vouchers-accountings', 'VouchersAccountingController');
Route::get('vouchers-accountings', 'VouchersAccountingController@index')->name('vouchers-accountings.index');
Route::post('vouchers-accountings', 'VouchersAccountingController@search')->name('vouchers-accountings.search');
});
Please or to participate in this conversation.