mercredi 9 août 2017

Laravel 5.4 checkbox checked while updating records

I am trying to check the checkbox from the database for the users which are associated with the selected project.

When i link the model with form, the select boxes and text box works properly. But my checkboxes are linked to the child table.

Is it possible to link with the model directly?

Here is my Code

Blade

{!!Form::model($Project, ['method' => 'PATCH' ..................
@foreach ($User as $Users)
<br /> 
@endforeach

Model

public function users(){return $this->belongsToMany('App\User');}

Controller

$User = User::orderBy('name','ASC')->get();
$Project = Project::find($id);
//$users = $Project->users();
//$services = $Project->services();
return view('projects.create',compact('Project', 'User'));




Aucun commentaire:

Enregistrer un commentaire