dollar dollar - 6 months ago 52
PHP Question

values modified by eloquent create() in laravel 5.2

I am creating a code by which i can replicate the multiple rows of table and its related tables.

I am able to replicate parent table successfully, but while replicating the contents of child table it is modifying the values which i am unable to figure it out.

my controller code is

public function copyshowtime($cinema_id,$show_date)
$date=new Carbon($show_date);


foreach ($movieshowtime as $item)

foreach ($item->showdata as $sd)

$newshowdata = array(
'showdata_id' => NULL,


// print_r($newshowdata);

When I am printing the complete array its showing proper data which i am trying to insert ,check below

enter image description here

But after inserting it into table I see this data in table, the values of show_id and showdata_rate is getting zero value and other columns getting correct data inserted.

enter image description here

I am unable to figure out this problem as I am nowhere changing the data to zero before inserting it into table.


Make sure show_id and showdata_rate are fillable in your Movies_showdata model:

class Movies_showdata extends Model {
  protected $fillable = ['show_id', 'showdata_rate', ...other fillable fields ];