I have a dropdown that the value of the dropdown is on another table .. and I plucked it so here it is I am getting 1 to display and not Sample Client 3 value which the dropdown has.. help thanks.
See here my dropdown and its value
See my dropdown, when I choose Sample Client it will insert 0 and NOT the ACTUAL string why is that? please take a look at my code thanks
My Dropdown Input
My Controller
On create function here it is
$clients = Client::all()->pluck('client_name');
return view('admin.movies.create', compact('clients'));
on View Index which I foreach loop here it is
<td></td>
and my Database Model Relationship
On the CLIENT side
class Client extends Model
{
use SoftDeletes;
protected $dates = ['deleted_at'];
// Table Name
protected $table = 'clients';
// Primary Key
public $primaryKey = 'id';
// Timestamps
public $timestamps = true;
on the MOVIES side
public function movies(){
return $this->hasMany('App\Movie');
}
}
class Movie extends Model
{
// Table Name
protected $table = 'movies';
// Primary Key
public $primaryKey = 'id';
// Timestamps
public $timestamps = true;
public function clients(){
return $this->belongsTo('App\Client');
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire