Laravel 5.3 - 500 internal error when saving a new Eloquent model - laravel

When trying to create a new instance of my model Apartment I get a 500 (Internal Server Error). I have other /create/ routes that I use to create new instance of my models and they work properly and they're set up same as ApartmentController#create, but for some weird reason it doesn't work.
ApartmentController#create
/**
* Show the form for creating a new resource.
*
* #return \Illuminate\Http\Response
*/
public function create()
{
$addresses = Address::all();
return view('address/create')->with('addresses', $addresses);
}
ApartmentController#store
/**
* Store a newly created resource in storage.
*
* #param \Illuminate\Http\Request $request
* #return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$address = new Address();
$this->authorize('create', $address);
$validator = Validator::make($request->all(), [
'building_number' => 'required|integer',
'street' => 'required|string',
]);
if ($validator->fails()) {
return redirect('addresses/create')
->withErrors($validator)
->withInput();
}
$address->building_number = $request->building_number;
$address->street = $request->street;
$address->save();
return redirect('addresses/create');
}
View apartment/create
<div class="col-md-6">
#if (count($errors) > 0)
<div class="alert alert-danger">
<ul>
#foreach ($errors->all() as $error)
<li>{{ $error }}</li>
#endforeach
</ul>
</div>
#endif
<form class="form-horizontal" method="POST" action="{{ action("ApartmentController#store") }}">
<fieldset>
<!-- Form Name -->
<legend>Register a new apartment</legend>
{{ csrf_field() }}
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="address_id">Address</label>
<div class="col-md-4">
<select id="address_id" name="address_id" class="form-control">
#foreach($addresses as $address)
<option value="{{$address->id}}">{{$address->street}} {{$address->building_number}}</option>
#endforeach
</select>
<span class="help-block">Apartments building number</span>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="apartment_number">Apartment Number</label>
<div class="col-md-4">
<input id="apartment_number" name="apartment_number" type="text" placeholder="2402" class="form-control input-md" required="">
<span class="help-block">The apartment number</span>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="size">Apartment Size</label>
<div class="col-md-4">
<input id="size" name="size" type="text" placeholder="56qm" class="form-control input-md" required="">
<span class="help-block">The size of the apartment in qm</span>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="living_area_size">Living Area Size</label>
<div class="col-md-4">
<input id="living_area_size" name="living_area_size" type="text" placeholder="23qm" class="form-control input-md" required="">
<span class="help-block">The size of the living area in qm</span>
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="suitable_for">Suitable For</label>
<div class="col-md-4">
<select id="suitable_for" name="suitable_for" class="form-control">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<span class="help-block">Number of people the apartment is suitable for.</span>
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="furnished">Furnished</label>
<div class="col-md-4">
<select id="furnished" name="furnished" class="form-control">
<option value="1">Yes</option>
<option value="0">No</option>
</select>
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="balcony_or_terrace">Balcony or Terrace</label>
<div class="col-md-4">
<select id="balcony_or_terrace" name="balcony_or_terrace" class="form-control">
<option value="none">None</option>
<option value="balcony">Balcony</option>
<option value="terrace">Terrace</option>
</select>
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="floor">Floor</label>
<div class="col-md-4">
<select id="floor" name="floor" class="form-control">
<option value="ground">Ground</option>
<option value="first">First</option>
<option value="second">Second</option>
<option value="third">Third</option>
</select>
</div>
</div>
<!-- Textarea -->
<div class="form-group">
<label class="col-md-4 control-label" for="description">Description</label>
<div class="col-md-6">
<textarea class="form-control" id="description" name="description"></textarea>
</div>
</div>
<!-- Button -->
<div class="form-group">
<label class="col-md-4 control-label" for="submit"></label>
<div class="col-md-4">
<button id="submit" name="submit" type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</fieldset>
</form>
</div>
<div class="col-md-4">
<legend>Registered Apartments</legend>
#foreach($apartments as $apartment)
<div class="address">
Apartment {{ $apartment->apartment_number }}
<a href="{{ url('/apartments/' . $apartment->id . '/edit') }}"
onclick="event.preventDefault();
document.getElementById('edit-form-{{$apartment->id}}').submit();">
<button class="btn btn-default">Edit</button>
</a>
<form id="edit-form-{{$apartment->id}}" action="{{ url('/apartments/' . $apartment->id . '/edit') }}" method="GET" style="display: none;">
{{ csrf_field() }}
<input type="hidden" name="address_id" value="{{$apartment->id}}">
</form>
<a href="{{ url('/apartments/' . $apartment->id) }}"
onclick="event.preventDefault();
document.getElementById('delete-form-{{$apartment->id}}').submit();">
<button class="btn btn-warning">Delete</button>
</a>
<form id="delete-form-{{$apartment->id}}" method="POST" action="/apartments/{{$apartment->id}}">
{{ csrf_field() }}
{{ method_field('DELETE') }}
</form>
</div>
<br>
#endforeach
</div>
Route web.php
Route::resource('apartments', 'ApartmentController');
apartments table for Apartment model
I tried to catch the exception on the save() method, but nothing is being caught and I still get redirected to /apartments without any Laravel error just Chroms 500 error page.
This is how I tried to catch the error using dwightwatson/validating:
try{
$apartment = new Apartment();
$apartment->apartment_number = $request->apartment_number;
$apartment->size = $request->size;
$apartment->living_area_size = $request->living_area_size;
$apartment->suitable_for = $request->suitable_for;
$apartment->furnished = $request->furnished;
$apartment->balcony_or_terrace = $request->balcony_or_terrace;
$apartment->floor = $request->floor;
$apartment->description = $request->description;
$apartment->address_id = $request->address_id;
$apartment->saveOrFail();
} catch (ValidationException $e) {
$errors = $e->getErrors();
return redirect()->route('apartments.create')
->withErrors($errors)
->withInput();
}

First of all, you Download Fiddler if you haven't already. Fire it up and then trigger the store method again. Fiddler should tell you a great deal about your request and response:
On the left side, you have a list of requests and on the right, you have statistics and inspectors. Under inspectors tab you will see WebView. Click it and you will see the error generated by Laravel.
As for why it might be failing, check if the references are included properly. e.g:
use App\Address;

Related

Laravel forms don't proccess external urls

I have an application in Laravel 8 running in Cpanel. I have a form to edit blog posts. When I insert an external image to display in the body of the post and save the form the application crashes. when I remove the image the form works.
BadMethodCallException
Method App\Http\Controllers\Backend\NewsBackController::show does not exist.
The same app in another server works fine.
Update in controller
public function update(Request $request, $id)
{
$post = Post::find($id);
$post->title = $request->input('title');
$post->slug = $request->input('slug');
$post->sumary = $request->input('sumary');
$post->content = $request->input('content');
$post->img = $request->input('img');
$post->tag_id = $request->input('tag_id');
$post->pub_date = $request->input('pub_date');
$post->status = $request->input('status');
$post->save();
return redirect('backend-news/'.$id.'/edit')->with('success', 'Successful update!');
}
Form in blade
#csrf
<div class="row">
<div class="col-md-8">
<div class="form-group ">
<label >Title</label>
<input type="text" name='title' class="form-control" #if(!empty($content->title)) value="{{$content->title}}" #endif required>
</div>
#if ($form == 'update')
<div class="form-group ">
<label>Slug</label>
<input type="text" name='slug' class="form-control" #if(!empty($content->slug)) value="{{$content->slug}}" #endif>
</div>
#endif
<div class="form-group ">
<label >Sumary <small>(120 characters max.)</small></label>
<textarea name="sumary" class="form-control" rows="4">#if(!empty($content->sumary)){{$content->sumary}} #endif</textarea>
</div>
<div class="form-group ">
<label >Content</label>
<textarea name="content" class="form-control summernote" rows="15">#if(!empty($content->content)){{$content->content}} #endif</textarea>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>Image Large <small>(120 characters max.)</small></label>
<input type="text" name='img' class="form-control" #if(!empty($content->img)) value="{{$content->img}}" #endif>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group ">
<label for='group'>Tags</label>
<select class="form-control m-b" name="tag_id">
<option value='0'>--SELECT--</option>
#foreach ($tags as $tag)
#php
if($form == 'update'){
$selected = ($content->tag_id == $tag->id)?'selected':'';
}else{
$selected = '';
}
#endphp
<option value='{{$tag->id}}' {{$selected}}>{{$tag->name}}</option>
#endforeach
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group ">
<label >Pub Date</label>
<div class="input-group date">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span><input type="text" class="form-control" name='pub_date'
#if (!empty($content->pub_date))
value="{{$content->pub_date}}"
#else
value="{{date('Y-m-d')}}"
#endif
>
</div>
</div>
</div>
</div>
<div class="form-group ">
<label for='group'>Status</label>
<select class="form-control m-b" name="status">
#if ($form == 'update')
#if ($content->status == 1)
<option value='1' selected>Published</option>
<option value='0'>Unpublish</option>
#else
<option value='1'>Published</option>
<option value='0' selected>Unpublish</option>
#endif
#else
<option value='1'>Published</option>
<option value='0'>Unpublish</option>
#endif
</select>
</div>
<div class="hr-line-dashed"></div>
<button type="submit" class="btn btn-w-m btn-success">Save</button>
#if(!empty($put))
<input type="hidden" name="_method" value="PUT">
#endif
<i class="fas fa-undo-alt"></i> Return
</div>
</div>
Thanks
First double check your controller, does it have show function or not?
If show function exists, run following artisan command:
php artisan cache:clear
php artisan config:cache
php artisan view:clear
php artisan route:clear
If show function doesn't exists, create it.
Hope this will be useful.

Laravel : Create Button returns the same view but blank and does not create any record

I am new to laravel and I am working on creating a CMS. I have created a view to create posts but after I input data and click create to submit, page refreshes and shows the same view but with no input and no record created, when it should show a flash message and return the posts index view.
Here is my VIEW HTML:
#section('content')
<div class="card card-default">
<div class="card-header">
{{ isset($post) ? 'Edit Post' : 'Create Post' }}
</div>
<div class="card-body">
<form action="{{ isset($post) ? route('posts.update', $post->id) : route('posts.store') }}" method="POST" enctype="multipart/form-data">
#csrf
#if (isset($post))
#Method('PUT')
#endif
<div class="form-group">
<label for="title">Title</label>
<input type="text" class="form-control" name="title" id="title" value="{{isset($post) ? $post->title : ""}}">
</div>
<div class="form-group">
<label for="description">Description</label>
<textarea name="description" id="description" cols="5" rows="3" class="form-control">{{isset($post) ? $post->description : ""}}</textarea>
</div>
<div class="form-group">
<label for="content">Content</label>
<input id="content" type="hidden" name="content" value="{{isset($post) ? $post->content : ""}}">
<trix-editor input="content"></trix-editor>
</div>
<div class="form-group">
<label for="published_at">Published at</label>
<input type="text" class="form-control" name="published_at" id="published_at" value="{{isset($post) ? $post->published_at : ""}}">
</div>
#if (isset($post))
<div class="form-group">
<img src="{{ asset('/storage/'.$post->image) }}" alt="" style="width: 100%">
</div>
#endif
<div class="form-group">
<label for="category">Category</label>
<select name="category" id="category" class="form-control">
#foreach($categories as $category)
<option value="{{$category->id}}">{{$category->title}}</option>
#endforeach
</select>
</div>
<div class="form-group">
<label for="image">Image</label>
<input type="file" class="form-control" name="image" id="image">
</div>
<div class="form-group">
<button type="submit" class="btn btn-success">
{{ isset($post) ? 'Update Post' : 'Create Post' }}
</button>
</div>
</form>
</div>
</div>
#endsection
Here is METHOD:
public function store(CreatePostRequest $request)
{
$image = $request->image->store('posts');
Post::create([
'title'=>$request->title,
'description'=>$request->description,
'image'=>$image,
'content'=>$request->content,
'published_at' => $request->published_at,
'category_id' => $request->category
]);
session()->flash('success', 'Post Created Successfully');
return redirect(route('posts.index'));
}
What am I doing wrong?
Thanks,

Error "The PATCH method is not supported for this route. Supported methods: GET, HEAD, POST. " update method

Well hello there, I am trying to update a register of my table assistants, but when I push the button submit of the form, this error appear, I am using a table pivot between assistants and events, but i am only try to edit a assistant.This is the error
This is my code AssistantController.php file and the methods edit and update
edit and update methods
public function edit(Assistant $assistant)
{
#obtain id assistant
$assistant_id = $assistant->id;
#get data event of the assistant to pass to the form
$event = Assistant::find($assistant_id)->events()->get();
return view('assistants.edit',compact('assistant','event'));
}
public function update(Request $request, Assistant $assistant)
{
#updating
$assistant->update($request->all());
//$assistants->user()->associate(Auth::user());
//
#obtain id assistant
$assistant_id = $assistant->id;
#get data event of the assistant to pass to the form
$event = Assistant::find($assistant_id)->events()->get();
return redirect('assistants.index',compact('assistant','event'));
}
This is my form to assistants
input form assistants
#csrf
<div class="form-group">
<label for="id">Document:</label>
<small class="text-muted">Required(*)</small>
<input type="number" class="form-control form-control-sm " value="{{ old('id') ?? $assistant->id }}" name="id" autofocus>
<div>{{ $errors->first('id') }}</div>
</div>
<div class="form-group">
<label for="name">Name:</label>
<small class="text-muted">Required(*)</small>
<input type="text" class="form-control form-control-sm " value="{{ old('name') ?? $assistant->name }}" name="name" placeholder="First Name assistant">
<div>{{ $errors->first('name') }}</div>
</div>
<div class="form-group">
<label for="last_name">Last name:</label>
<small class="text-muted">Required(*)</small>
<input type="text" class="form-control form-control-sm " value="{{ old('last_name') ?? $assistant->last_name }}" name="last_name" placeholder="Last name assistant">
<div>{{ $errors->first('last_name') }}</div>
</div>
<div class="form-group">
<label for="phone">Phone:</label>
<small class="text-muted">Required(*)</small>
<input type="number" class="form-control form-control-sm " value="{{ old('phone') ?? $assistant->phone }}" name="phone">
<div>{{ $errors->first('phone') }}</div>
</div>
<div class="form-group">
<label for="email">Email:</label>
<small class="text-muted">Required(*)</small>
<input type="mail" class="form-control form-control-sm " value="{{ old('email') ?? $assistant->email }}" name="email">
<div>{{ $errors->first('email') }}</div>
</div>
<div class="form-group">
<label for="observations">Observations:</label>
<input type="text" class="form-control form-control-sm " value="{{ old('observations') ?? $assistant->observations }}"name="observations">
<div>{{ $errors->first('observations') }}</div>
</div>
This is my edit page
#extends('layouts.back')
#section('title','Edit assistants')
#section('content')
<div class="container p-4">
<div class="row">
<div class="card">
<div class="card-header">
<div class="card-title">
<h3>Edit details to assistant:</h3><br>
<h4><strong> {{$assistant->name}} {{$assistant->last_name}}</strong> </h4>
</div>
</div>
<div class="card-body">
<form action="/assistants" method="POST">
#method('PATCH')
#include('assistants.form')
<button type="submit" class="btn btn-primary">Update</button>
Cancel
</form>
</div>
<div class="card-footer">
</div>
</div>
</div>
</div>
#endsection
There are my routes
routes
Auth::routes();
Route::get('/', 'HomeController#index')->name('home');
Route::resource('events', 'EventController');
Route::resource('assistants', 'AssistantController');
Route::resource('certificates', 'CertificateController');
Route::resource('signers', 'SignerController');
I am beginner.
thank you all.
In your edit page, change your form action from
<form action="/assistants" method="POST">
to
<form action="/assistants/{{ $assistant->id }}" method="POST">
Without the assistant id in the action field, Laravel thinks you are trying to update the base assistants route, which is an invalid action for that route.

Error About Laravel Blade Foreach in Loop if else

There are problem my code about foreach and if condition. When I pulled else code block out of foreach loop there are no problem it is work. But I put in else code in loop. Else dont work and dont show anything.
My purpose, programme check to used user_id in total_bonuses datatable if ok I want to display only update form if no records user_id in total_bonuses I want to show store forum and user add to info. It seems to complicated.
My controller code is below
public function show($lang=null, $id)
{
$bonuses = DB::table('reservations')
->select(DB::raw('SUM(bonus) as total_bonus, user_id'))
->where('user_id', '=', $id)
->groupBy('user_id')
->get();
$dolars = DB::table('reservations')
->select(DB::raw('SUM(dolar) as dolar, user_id'))
->where('user_id', '=', $id)
->groupBy('user_id')
->get();
$confirmeds = DB::table('reservations')
->select(DB::raw('SUM(confirmation) as confirmed, user_id'))
->where('confirmation', '=', 1)
->where('user_id', '=', $id)
->groupBy('user_id')
->get();
$user = DB::table('users')->find($id);
$totals = DB::table('total_bonuses')->where('user_id', '=', $id)->get();
return view('wallet.show', compact('totals', 'user', 'bonuses', 'dolars', 'confirmeds'));
}
View Code is below
#foreach ($totals as $total)
#if ($total->new_dollar !== NULL)
<div class="col-12"><a href="javascript:void(0)" class="link"><i class="mdi mdi-check-circle text-success"></i> <font class="font-medium"> {!! $total->new_dollar !!}
Remaining Dollar</font></a></div>
#endif
</div>
</center>
</div>
<div>
</div>
</div>
</div>
<!-- Column -->
<!-- Column -->
<div class="col-lg-8 col-xlg-9 col-md-7">
<div class="card">
#if (count($total->user_id) === 1)
<br>
<br>
<label class="col-md-12"><h4> Paid Dollar</h4></label>
<form class="form-horizontal form-material" method="POST" action="{{ route ('total.update', ['lang' => App::getLocale(), 'id' => $total->id]) }}">
{{ csrf_field() }}
<input type="hidden" name="_method" value="PATCH">
<input type="hidden" name='id' value='{!! $total->id !!}'>
<input type="hidden" name='user_id' value='{!! $user->id !!}'>
<div class="form-group">
<label class="col-md-12">Total Dollar</label>
<div class="col-md-12">
<input name="old_dollar" type="text" value="{!! $total->new_dollar !!}" class="form-control form-control-line" readonly>
</div>
</div>
<div class="form-group">
<label class="col-md-12">Paid Dollar</label>
<div class="col-md-12">
<input name="paid_dollar" type="text" class="form-control form-control-line">
</div>
</div>
<div class="form-group">
<label class="col-md-12">Note (Optionally! Not Required)</label>
<div class="col-md-12">
<input name="bonus_note" type="text" class="form-control form-control-line">
</div>
</div>
<input name="moderator_id" type="hidden" value="{{ Auth::user()->id }}">
<div class="form-group">
<div class="col-sm-12">
<button class="btn btn-success" type="submit">{{ __('profile.update')}}</button>
</div>
</div>
</form>
#else
<form class="form-horizontal form-material" method="POST" action="{{ route ('total.store', ['lang' => App::getLocale()]) }}">
{{ csrf_field() }}
<input type="hidden" name='user_id' value='{!! $user->id !!}'>
<div class="form-group">
<label class="col-md-12">Total Dollar</label>
<div class="col-md-12">
<input name="old_dollar" type="text" value="#foreach ($dolars as $dolar)
{{ $dolar->dolar }}
#endforeach" class="form-control form-control-line" readonly>
</div>
</div>
<div class="form-group">
<label class="col-md-12">Paid Dollar</label>
<div class="col-md-12">
<input name="paid_dollar" type="text" class="form-control form-control-line">
</div>
</div>
<div class="form-group">
<label class="col-md-12">Note (Optionally! Not Required)</label>
<div class="col-md-12">
<input name="bonus_note" type="text" class="form-control form-control-line">
</div>
</div>
<input name="moderator_id" type="hidden" value="{{ Auth::user()->id }}">
<div class="form-group">
<div class="col-sm-12">
<button class="btn btn-success" type="submit">{{ __('profile.update')}}</button>
</div>
</div>
</form>
#endif
#endforeach
Best wishes.
The problem in your provided view is with the if condition. Here you are trying to count the user id which is not possible:-
#if (count($total->user_id) === 1)
Change the above code to
#if (count($total) === 1)

When Pass pdf file in ajax call then file_get_content() gives error

When i try to pass pdf at controller side through ajax at that time file_get_content() gives error like this
file_get_contents(): Filename cannot be empty
My output is like below:-
Illuminate\Http\UploadedFile Object(
[test:Symfony\Component\HttpFoundation\File\UploadedFile:private] =>
[originalName:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 2017-playing-rules.pdf
[mimeType:Symfony\Component\HttpFoundation\File\UploadedFile:private] => application/octet-stream
[size:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 0
[error:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 1
[hashName:protected] =>
[pathName:SplFileInfo:private] =>
[fileName:SplFileInfo:private] =>
)
Here "[pathName:SplFileInfo:private]=>" gives null response which should have temp path of my uploaded file.
Here is my ajax call:-
$('#formAddLeague').on('success.form.bv', function(e) {
e.preventDefault();
var formData = new FormData(this);
$.ajax({
url:'{{ url('restoreleague') }}',
data:formData,
type:'post',
dataType:'json',
cache: false,
contentType: false,
processData: false,
success: function(data)
{
$('#loader').hide();
if(data.key == 1)
{
notify('League has been updated Successfully.','blackgloss');
}
}
});
});
In controller i used following:-
$import_rule = $request->file('importRule');
Here is my controller:-
public function restore(Request $request)
{
$league_id = $request->get('hiddenLeagueId');
$import_rule = $request->file('importRule');
$league_rule_url = $request->get('txtLeagueRule');
$objLeague = League::find($league_id);
if (!empty($import_rule)) {
$originalName = $import_rule->getClientOriginalName();
$ruleFileName = pathinfo($originalName, PATHINFO_FILENAME) . '.' . pathinfo($originalName, PATHINFO_EXTENSION);
$s3 = Storage::disk('s3');
$filePath = 'league_rules/' . $ruleFileName;
if ($s3->put($filePath, file_get_contents($import_rule) , 'public'))
{
$ruleURL = $s3->url($filePath);
$objLeague->league_rules = $ruleURL;
$objLeague->rules_filename = $ruleFileName;
}
}
else
if (!empty($league_rule_url))
{
$checkExtension = pathinfo($league_rule_url, PATHINFO_EXTENSION);
if ($checkExtension != 'pdf')
{
$msg = "The selected url extension is not valid.";
return $msg;
}
else
{
$objLeague->league_rules = $league_rule_url;
}
}
$objLeague->league_name = $request->get('txtLeagueName');
$objLeague->league_email = $request->get('txtLeagueEmail');
$objLeague->league_phone = $this->replacePhoneNumber($request->get('leagueContactNo'));
$objLeague->league_info = $request->get('txtLeagueInfo');
$objLeague->level_id = $request->get('txtLevel');
$objLeague->age_required = $request->get('txtMinRequiredAge');
$objLeague->league_website = $request->get('leagueWebsite');
$objLeague->save();
$response['key'] = 1;
return $response;
}
Here is my form:-
<div id="tab2" class="tab-pane">
<form id="formAddLeague" method="post">
{{ csrf_field() }}
<input id="hiddenLeagueId" type="hidden" name="hiddenLeagueId" value="{{$leagueDetail->league_id or ''}}">
<div class="row">
<div class="col-md-8">
<div class="form-group">
<label class="control-label"><b>LEAGUE NAME</b></label>
<input type="text" id="txtLeagueName" name="txtLeagueName" value="{{$leagueDetail->league_name or ''}}" class="form-control">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="control-label"><b>LEAGUE ID</b></label><br>
<span class="disabled-color" id="leagueId">{{$leagueDetail->league_id or ''}}</span>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label class="control-label"><b>TYPE OF LEAGUE</b></label>
<select id="txtLevel" name="txtLevel" class="form-control">
<option value="">-- Select Type of League --</option>
#foreach($levelList as $level)
<option value="{{ $level->level_id }}" #if($leagueDetail->level_id == $level->level_id) {{"selected='selected'"}} #endif>{{ $level->level_name }}</option>
#endforeach
</select>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="control-label"><b>MIN AGE REQUIREMENT</b></label>
<select id="txtMinRequiredAge" name="txtMinRequiredAge" class="form-control">
<option value="ALL AGES" #if($leagueDetail->age_required == 'ALL AGES') {{ "selected='selected'" }} #endif>All AGES</option>
<option value="18 AND OVER" #if($leagueDetail->age_required == '18 AND OVER') {{ "selected='selected'" }} #endif>18 AND OVER</option>
</select>
</div>
</div>
<div class="col-md-4">
<div class="form-group" style="overflow: visible!important;">
<label class="control-label"><b>SPORTS OFFERED</b></label>
<select id="txtLevel" name="txtLevel" class="form-control selectpicker" multiple data-style="form-control">
#foreach($levelList as $level)
<option value="{{ $level->level_id }}" #if($leagueDetail->level_id == $level->level_id) {{"selected='selected'"}} #endif>{{ $level->level_name }}</option>
#endforeach
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label class="control-label"><b>LEAGUE EMAIL</b></label>
<input style="text-transform: lowercase;" type="email" id="txtLeagueEmail" name="txtLeagueEmail" value="{{$leagueDetail->league_email or ''}}" class="form-control" placeholder="Enter Your Email">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="control-label"><b>LEAGUE PHONE</b></label>
<input placeholder="(xxx) xxx-xxxx" type="text" name="leagueContactNo" id="leagueContactNo" value="{{$leagueDetail->league_phone or ''}}" class="form-control">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="control-label"><b>LEAGUE WEBSITE</b></label>
<input id="leagueWebsite" type="text" name="leagueWebsite" value="{{$leagueDetail->league_website or ''}}" class="form-control" placeholder=" League website">
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label class="control-label"><b>LEAGUE RULES</b></label>
<div class="row">
<div class="col-md-1">
<div class="radio radio-info">
<input type="radio" name="user_radio" id="file_radio" onclick="leagueRule(1)" checked>
<label> Use File </label>
</div>
</div>
<div class="col-md-11">
<div class="col-sm-12">
<div class="fileinput fileinput-new input-group" data-provides="fileinput">
<div class="form-control" data-trigger="fileinput">
<i class="glyphicon glyphicon-file fileinput-exists"></i>
<span class="fileinput-filename"></span>
</div>
<span class="input-group-addon btn btn-default btn-file">
<span class="fileinput-new"><i class="fa fa-upload"></i></span>
<span class="fileinput-exists">Change</span>
<input type="file" name="importRule" id="importRule">
</span>
Remove
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-1">
<div class="radio radio-info">
<input type="radio" name="user_radio" id="url_radio" onclick="leagueRule(2)">
<label> Use URL </label>
</div>
</div>
<div class="col-md-11">
<input disabled type="text" id="txtLeagueRule" name="txtLeagueRule" value="{{$leagueDetail->league_rules or '' }}" class="form-control" placeholder="Enter Link">
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group col-md-12 col-sm-12 col-xs-12">
<label class="control-label"><b>ABOUT</b></label>
<textarea id="txtLeagueInfo" style="resize: none;" class="form-control" rows="3" data-minwords="3" maxlength="238" name="txtLeagueInfo" placeholder="Type your message">{{$leagueDetail->league_info or ''}}</textarea>
<div id="textarea_feedback" style="text-align:right; color: red"></div>
{{-- <div id="textarea_feedback" class="text-left disabled-color"></div> --}}
</div>
</div>
</div>
<div class="form-group text-left p-t-md">
<button type="submit" class="btn btn-info">UPDATE</button>
</div>
</form>
</div>

Resources