app/Http/Controllers/ServicesController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(ServiceRequest $request)
    {
        $renewal_field = [
            'amount',
            'deadline',
            'status'
        ];
        $service = Service::create($request->except($renewal_field));
        $current = $service->renewals()->create($request->only($renewal_field));
        if(
            $current->stateIs() != RenewalSM::S_suspended &&
            $current->stateIs() != RenewalSM::S_to_confirm
        ) {
            $service->renewals()->create([
                'deadline' => $service->calcNextDeadline(),
                'amount' => $current->amount
            ]);
        }
        return redirect()->route('services.show', $service)
            ->with('status', __('messages.service_created_status'));
    }
public function store ( ServiceRequest $ request ) { $ renewal_field = [ 'amount' , 'deadline' , 'status' ] ; $ service = Service :: create ( $ request -> except ( $ renewal_field ) ) ; $ current = $ service -> renewals ( ) -> create ( $ request -> only ( $ renewal_field ) ) ; if ( $ current -> stateIs ( ) != RenewalSM :: S_suspended && $ current -> stateIs ( ) != RenewalSM :: S_to_confirm ) { $ service -> renewals ( ) -> create ( [ 'deadline' => $ service -> calcNextDeadline ( ) , 'amount' => $ current -> amount ] ) ; } return redirect ( ) -> route ( 'services.show' , $ service ) -> with ( 'status' , __ ( 'messages.service_created_status' ) ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
// Create the service // Create the renewal // Create the next renewal