0

I'm using the replicate eloquent and it doesn't work on me. Replicate the row in database with changing some columns and it will save by clicking the button, can you please help me? My coding for controller

   public function newpayrolls(Request $request, $id){
    $newpay = Payroll::find($id);
    $newpay = $newpay->replicate();
    $newpay->id = $new_id;
    $newpay->data = $new_data;
    $newpay->save();
     return redirect("/payroll");

Coding for my blade.php

 <button class ="btn btn-primary btnd" type="submit" value="Submit">
      <span class="glyphicon glyphicon-arrow-left small"></span> Save as 
 new Payroll
    </button>
    </div>

And this is my route

Route::get('/viewpayrolls/{id}','PayrollController@newpayrolls');
shyy
  • 17
  • 4
  • You are going to have to provide a lot more detail to receive any help. Please review [how to ask a question](https://stackoverflow.com/help/how-to-ask). Welcome to Stack Overflow! – busybear Jan 31 '19 at 02:56
  • If the above code is really your controller then you have 2 variables that are undefined. `$new_id` and `$new_data` – Linus Juhlin Jan 31 '19 at 03:32
  • Here's an example, including relationships: https://stackoverflow.com/questions/36021239/laravel-eloquent-orm-replicate – Antony Thompson Jan 31 '19 at 04:00
  • Possible duplicate of [Laravel Eloquent ORM replicate](https://stackoverflow.com/questions/36021239/laravel-eloquent-orm-replicate) – Linus Juhlin Jan 31 '19 at 04:12

0 Answers0