Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.3 kB
1
Indexable
Never
if (Input::has('partners') && count(Input::get('partners')) > 0) {
                $partners_list = [];
                foreach (Input::get('partners') as $partner) {
                    // Check if added partner is a valid user
                    if ($partner['user_id'] === null || $partner['user_id'] === '' || $partner['user_id'] === 0) {
                        DB::rollback();
                        throw new \Exception('Partner doesnot exist.');
                    }
                    $partner_user = \User::find($partner['user_id']);
                    if ($partner_user === null) {
                        DB::rollback();
                        throw new \Exception('Partner doesnot exist.');
                    }
                    array_push($partners_list, [
                        'user_id' => $partner['user_id'],
                        'meeting_id' => $meeting->id,
                        'static_revenue' => 0,
                        'dynamic_revenue' => $partner['dynamic_revenue'],
                        'only_onwards_revenue' => false,
                        'partner_type' => $partner['partner_type']
                    ]);
                }
                MeetingSplitRevenue::insert($partners_list);
            }