Please see the code below, can't figure out what is wrong but insert is not happening... any ideas on how to debug/fix
Laravel - Controller
namespace App\Http\Controllers;
use App\Models\PhoneContactsPhonesModel;
use Illuminate\Http\Request;
class CreatePhoneContactsController extends Controller
{
public function create(Request $request, $id)
{
$users = new PhoneContactsPhonesModel;
$json = dd(json_decode($request->getContent(), true));
foreach ($json as $key => $value) {
$users->mysql_user_id = $id;
$users->phone = $key;
$users->name = $value;
$users->save();
}
}
}
Laravel - Route
Route::post('create_phone_contacts/{id}', 'CreatePhoneContactsController@create');
Something is wrong with foreach loop - it seems to be working well with hardcoded values outside the loop
dd(). That function will dump the value and terminate the execution of the script, so the foreach loop will never be executed..