Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nacha's avatar
Level 2

how to change Laravel Collective to regular html?

How to change Laravel Collective to regular html? and thank you very much reportController:

public function __construct()
	{
	

		$this->data['exports'] = [
			'xlsx' => 'Excel File',
			'pdf' => 'PDF File',
		];
	}
public function revenue(Request $request)
	{
	
if ($exportAs = $request->input('export')) {
			if (!in_array($exportAs, ['xlsx', 'pdf'])) {
				\Session::flash('error', 'Invalid export request');
				return redirect('admin/reports/revenue');
			}

			if ($exportAs == 'xlsx') {
				$fileName = 'report-revenue-'. $startDate .'-'. $endDate .'.xlsx';

				return Excel::download(new ReportRevenueExport($revenues), $fileName);
			}

			if ($exportAs == 'pdf') {
				$fileName = 'report-revenue-'. $startDate .'-'. $endDate .'.pdf';
				$pdf = PDF::loadView('admin.reports.exports.revenue_pdf', $this->data);

				return $pdf->download($fileName);
			}
		}
}

filter.blade.php:

{!! Form::open(['url'=> Request::path(),'method'=>'GET','class' => 'input-daterange form-inline']) !!}
	<div class="form-group mb-2">
		<input type="text" class="form-control datepicker" readonly="" value="{{ !empty(request()->input('start')) ? request()->input('start') : '' }}" name="start" placeholder="from">
	</div>
	<div class="form-group mx-sm-3 mb-2">
		<input type="text" class="form-control datepicker" readonly="" value="{{ !empty(request()->input('end')) ? request()->input('end') : '' }}" name="end" placeholder="to">
	</div>
	<div class="form-group mx-sm-3 mb-2">
		{{ Form::select('export', $exports, !empty(request()->input('export')) ? request()->input('export') : null, ['placeholder' => '-- Export to --', 'class' => 'form-control input-block']) }}
	</div>
	<div class="form-group mx-sm-3 mb-2">
		<button type="submit" class="btn btn-primary btn-default">Go</button>
	</div>
{!! Form::close() !!}

I changed it to this :

<form action="{{url('Request::path()')}}" method="GET" class="input-daterange form-inline" >
 @csrf
	<div class="form-group mb-2">
		<input type="text" class="form-control datepicker" readonly="" value="{{ !empty(request()->input('start')) ? request()->input('start') : '' }}" name="start" placeholder="from">
	</div>
	<div class="form-group mx-sm-3 mb-2">
		<input type="text" class="form-control datepicker" readonly="" value="{{ !empty(request()->input('end')) ? request()->input('end') : '' }}" name="end" placeholder="to">
	</div>

	<div class="form-group mx-sm-3 mb-2">
	
	<select name="export" id="" class="form-control input-block">
	<option value="{{!empty(request()->input('export')) ? request()->input('export') : null}}" >-- Export to --</option>
     @foreach($exports as $export)
     <option value="{{ $export }}" >{{ $export }}</option>
     @endforeach
</select>
	</div>
	<div class="form-group mx-sm-3 mb-2">
		<button type="submit" class="btn btn-primary btn-default">Go</button>
	</div>
	</form>

route:

Route::get('reports/revenue', 'ReportController@revenue');
		Route::get('reports/product', 'ReportController@product');
		Route::get('reports/inventory', 'ReportController@inventory');
		Route::get('reports/payment', 'ReportController@payment');

and what about 'url'=> Request::path() I don't understand how to use it and how to change it because if I used it I get this error:

Forbidden
You don't have permission to access this resource.
0 likes
7 replies
SilenceBringer's avatar
Level 55

@nacha some hints. First: you do not need quotes here

{{ url(Request::path() )}}

or try

{{ Request::path() }}

next - look at old helper https://laravel.com/docs/8.x/helpers#method-old and replace your inputs to

		<input type="text" class="form-control datepicker" readonly="" value="{{ old('start') }}" name="start" placeholder="from">
vincej's avatar

@Tray2

I was young and naive when I started working with Laravel ( L4.2 to be exact!) and back in those days collective was heralded even by Jeffrey as being the bees knees, and I dutifully did as I was told. Now I have hundreds probably thousands of lines of code with collective.

I'm just Just academically curious. Why is Collective garbage?

Tray2's avatar

@vincej Not sure why it was recommended in the first place. According to this stack overflow post it was removed from the framework to keep it slim. https://stackoverflow.com/questions/35695949/why-are-form-and-html-helpers-deprecated-in-laravel-5-x

The form helper really doesn't give any help but rather adding complexity to your code and making it less configurable and harder to read than just using regular html to build your forms.

I like the idea of a form builder but the way it should not be at runtime but rather an artisan command that generates the form once and in pure html.

nacha's avatar
Level 2

Thank You @silencebringer and @tray2 sorry but I can't get any file if I select Excel or PDF file and click go (sorry it's the first time that I use export:Excel and PDF) so what to do

Tray2's avatar

@nacha Start a new thread is the best way to get answers since its a completly different issue. It will give you answers faster if you do that.

Please or to participate in this conversation.