Getting error : syntax error, unexpected '=>' (T_DOUBLE_ARROW)
my code is :
#extends('layouts.masters.main')
#section('page-content')
<div class="container">
#include('layouts.partials.nav')
{!! Form::open(['route' => 'post_register', 'id' => 'registration-form']) !!}
{!! Form::label('name', 'Full Name') !!}
{!! Form::text('name', null, ['id' => 'name', 'class' => 'form-control', 'placeholder' => 'Full Name', 'required']) !!}
{!! Form::label('email', 'Email Address') !!}
{!! Form::email('email',null,['id' => 'email', 'class' => 'form-control', 'placeholder' => 'Email Address', 'required']) !!}
{!! Form::label('password', 'password') !!}
{!! Form::password('password',['id' => 'password', 'class' => 'form-control', 'placeholder' => 'password', 'required']) !!}
{!! Form::button('Register','class' => 'btn btn-lg btn-primary btn-block', 'type' => 'submit')!!}
{!! Form::close() !!}
</div> <!-- /container -->
#stop
please help ... i can't uderstand where i do the mistake in this code
When you use "=>" the content should be inside an array (class, type, etc..)
So, try this;
{!! Form::button('Register', ['class' => 'btn btn-lg btn-primary btn-block', 'type' => 'submit']) !!}
Related
This is my problem in SkladController. I want to fetch data from the DB but it does show me anything because I have that error in the picture.
SkladController
class SkladController extends Controller
{
public function index()
{
$sklads = Sklad::all();
return view('sklads.index')->with('sklads', $sklads);
}
public function create()
{
return view('sklads.index');
}
public function store(Request $request)
{
$this->validate($request, [
'datle' => 'required',
'mandle' => 'required',
'marcipan' => 'required',
'orechy' => 'required',
]);
//vytvorit v sklade
$sklads = new Sklad;
$sklads->datle = $request->input('datle');
$sklads->mandle = $request->input('mandle');
$sklads->marcipan = $request->input('marcipan');
$sklads->orechy = $request->input('orechy');
$sklads->save();
return redirect('/sklad')->with('success', 'Uložené');
}
}
index.blade.php
<h3> Príjem v sklade</h3>
<br>
{!! Form::open(['action' => 'App\Http\Controllers\SkladController', 'method' => 'POST']) !!}
<div class="row">
<div class="form-group col-md-2">
{{ Form::number('datle', '', ['class' => 'form-control', 'placeholder' => 'Ďatle']) }}
</div>
<div class="form-group col-md-2">
{{ Form::number('mandle', '', ['class' => 'form-control', 'placeholder' => 'Mandle']) }}
</div>
<div class="form-group col-md-2">
{{ Form::number('marcipan', '', ['class' => 'form-control', 'placeholder' => 'Marcipán']) }}
</div>
<div class="form-group col-md-2">
{{ Form::number('orechy', '', ['class' => 'form-control', 'placeholder' => 'Orechy']) }}
</div>
<div class="form-group col-md-2">
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }}
</div>
</div>
{!! Form::close() !!}
#if(count($sklads) > 0)
#foreach($sklads as $sklad)
<br>
{{$sklad->datle}} {{$sklad->mandle}} {{$sklad->marcipan}} {{$sklad->orechy}}
#endforeach
#else
<p>nenasli sa zaznamy</p>
#endif
web.php
Route::resource('/sklad', App\Http\Controllers\SkladController::class)
->except(['create', 'store', 'update', 'destroy']);
The issue is the action in
{!! Form::open(['action' => 'App\Http\Controllers\SkladController', 'method' => 'POST']) !!}
It should be
'action' => 'App\Http\Controllers\SkladController#index'
Usually you'd use the store method but you only don't have it according to your route declaration.
or you could use route instead.
{!! Form::open(['route' => 'sklads.index', 'method' => 'POST']) !!}
This code make below modal.
How can I add input field to this modal by Blade?
{!! Form::open(['route' => ['jobs.destroy', $job->id], 'method' => 'delete', 'class' => 'btn-group', 'id' => 'jobStop']) !!}
{!! Form::button('<i class="glyphicon glyphicon-stop"></i>', ['type' => 'submit', 'class' => 'btn btn-warning btn-xs', 'onclick' => "return confirm('Are you sure you want stop?')"]) !!}
{!! Form::close() !!}
I want make search by parameters. But it shows i have mixing GET and POST methods. (Error message: MethodNotAllowedHttpException
No message). Blade form by default have POST. i changed to GET. Route have GET method. Maybe you can see what i am doing wrong. This is my VIEW:
{!! Form::open([ 'action' => ['HomePageController#index', 'method' => 'get']]) !!}
<div class="container">
<div class="col-xs-2 form-inline">
{!! Form::label('city_id', trans('quickadmin.companies.fields.city').'', ['class' => 'control-label']) !!}
{!! Form::select('city_id', $cities, old('city_id'), ['class' => 'form-control select2') !!}
</div>
<div class="col-xs-3 form-inline">
{!! Form::label('categories', trans('quickadmin.companies.fields.categories').'', ['class' => 'control-label']) !!}
{!! Form::select('categories', $categories, old('categories'), ['class' => 'form-control select2']) !!}
</div>
<div class="col-xs-3 form-inline">
{!! Form::label('search', trans('quickadmin.companies.fields.name').'', ['class' => 'control-label']) !!}
{!! Form::text('search', old('search'), ['class' => 'form-control', 'placeholder' => 'Search']) !!}
</div>
<div class="form-inline">
<div class="col-xs-2">
<button type="submit"
class="btn btn-primary">
Search
</button>
</div>
</div>
</div>
{!! Form::close() !!}
My controller:
public function index( Request $request)
{
$cities = \App\City::get()->pluck('name', 'id')->prepend(trans('quickadmin.qa_please_select'), '');
$categories = \App\Category::get()->pluck('name', 'id')->prepend(trans('quickadmin.qa_please_select'), '');
$name = $request->input('city_id');
$companies = \App\Company::All()->where('city_id', '=', $name);
return view('table', compact('companies', $companies, 'cities', $cities, 'categories', $categories));
My route:
Route::get('/', 'HomePageController#index');
Thank you for your help.
There is a problem in the form open, try it like this :
{!! Form::open([ 'action' => 'HomePageController#index', 'method' => 'get']) !!}
I was wondering if someone can look at this code and tell me why it's not working. When I press the submit button, it will not submit.
{!! Form::open([
'method' => 'DELETE',
'route' => ['posts.destroy', $post->id],
'style' => 'display: inline'
]) !!}
{!! Form::submit('Delete this post?', ['class' => 'btn btn-danger']) !!}
{!! Form::close() !!}
I'm submitting it to a PostController's destory method, where the route is defined as 'posts'.
Route file
Route::group(['prefix' => 'admin'], function() {
Route::resource('posts', 'PostController');
});
Change
{!! Form::open([
'method' => 'DELETE',
'route' => ['posts.destroy', $post->id],
'style' => 'display: inline'
]) !!}
{!! Form::submit('Delete this post?', ['class' => 'btn btn-danger']) !!}
{!! Form::close() !!}
To
{!! Form::open([
'method' => 'DELETE',
'route' => ['admin.posts.destroy', $post->id],
'style' => 'display: inline'
]) !!}
{!! Form::submit('Delete this post?', ['class' => 'btn btn-danger']) !!}
{!! Form::close() !!}
Following your prefix in route. Hope it would help
New to Laravel, please bare with.
Error:
htmlentities() expects parameter 1 to be string, object given (View: /var/www/html/willow/resources/views/emails/valuation.blade.php)
The modal from which it is being sent:
{!! Form::open(['action' => ['EnquiryController#valuationRequest']]) !!}
<div class="form-group">
{!! Form::text('name', null, ['class' => 'form-control has-feedback', 'placeholder' => 'Name']) !!}
</div>
<div class="form-group">
{!! Form::text('email', null, ['class' => 'form-control has-feedback', 'placeholder' => 'Email Address']) !!}
</div>
<div class="form-group">
{!! Form::text('telephone', null, ['class' => 'form-control has-feedback', 'placeholder' => 'Telephone Number']) !!}
</div>
<div class="form-group">
{!! Form::text('house_number', null, ['class' => 'form-control has-feedback', 'placeholder' => 'House name / number']) !!}
</div>
<div class="form-group">
{!! Form::text('postcode', null, ['class' => 'form-control has-feedback', 'placeholder' => 'Postcode']) !!}
</div>
<div class="form-group">
{!! Form::textarea('message', null, ['class' => 'form-control has-feedback', 'placeholder' => 'Message', 'rows' => '5']) !!}
</div>
<div class="form-group">
<input type="submit" class="button black" value="Register">
</div>
{!! Form::close() !!}
and the function:
public function valuationRequest(ValuationRequest $request)
{
// dd($request->all());
Mail::send('emails.valuation',
['name' => $request['name'],
'email' => $request['email'],
'telephone' => $request['telephone'],
'house_number' => $request['house_number'],
'postcode' => $request['postcode'],
'message' => $request['message'],
],
function ($message) use ($request) {
$message->to('paolo#bigg.co.uk', 'Paolo Resteghini')->subject('Valuation Request - Willow Lettings');
});
Session::flash('flash_message', 'Your request has been sent.');
return redirect(URL::previous());
}
The contents of the DD are perfect. All of the requests are populated as expected, but when trying to go through the rest of the function it fails with the error above.
emails.valuation:
Hello, <br><br>
You have received a new valuation request via the Willow Lettings website. Here they are: <br><br>
<b>Name:</b> {{ $name }}<br>
<b>Email:</b> {{ $email }}<br>
<b>Phone:</b> {{ $telephone }}<br>
<b>House number:</b> {{ $house_number }}<br><br>
<b>Postcode:</b> {{ $postcode }}<br><br>
{{ $message }}
Most likely, this is a problem with your message variable. As you can see from the docs:
Note: A $message variable is always passed to e-mail views, and allows the inline embedding of attachments. So, you should avoid passing a message variable in your view payload.
In other words, you should change message into something else like msg.
'msg' => $request['message'],
Then, in your blade file, reflect that change:
{{ $msg }}