1 year ago

Two ids waiting for each other

Posted 1 year ago by Hourlee

I want to save a form into two tables. I have two models using in one controller. There are two ids that are waiting for each other. I don't know how to fix this. Please help

            $project = new Project;

            $project->project_name = $request->projectName;
            $project->start_date = date("Y-m-d", strtotime($request->start_date));
            $project->end_date = date("Y-m-d", strtotime($request->end_date));
            $project->description = $request->description;
            $project->created_by = Auth::user()->id;

            $scope = new Scope;
            $scope->project_id = $project->id;

            $rows = $request->get('rows');
            foreach ($rows as $row){

            $scope->features = ($row['features']);
            $scope->prices = ($row['prices']);



            $project->projectScope_id = $scope->id;

Please sign in or create an account to participate in this conversation.