vendredi 30 novembre 2018

Laravel - Dropdown Pluck Data Cannot Get the String Value

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

enter image description here

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');
     }
}



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2RqQZQ9
via IFTTT

Aucun commentaire:

Enregistrer un commentaire