Skip to content

Instantly share code, notes, and snippets.

@infinitbility
Created June 1, 2020 16:17
Show Gist options
  • Select an option

  • Save infinitbility/042c9c38294be2fd4567dbfe5526ddfe to your computer and use it in GitHub Desktop.

Select an option

Save infinitbility/042c9c38294be2fd4567dbfe5526ddfe to your computer and use it in GitHub Desktop.

Revisions

  1. infinitbility created this gist Jun 1, 2020.
    29 changes: 29 additions & 0 deletions ParentController.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    <?php

    namespace App\Http\Controllers;

    use App\Http\Controllers\Controller;
    use Illuminate\Http\Request;
    use App\Http\Controllers\ChildController;

    class ParentController extends Controller
    {
    protected $ChildController;
    public function __construct(ChildController $ChildController)
    {
    $this->ChildController = $ChildController;
    }

    /**
    * Parent function using child function
    */
    function calc(Request $Request){

    $firstNumber = $Request->input('firstNumber');
    $operator = $Request->input('operator');
    $secondnumber = $Request->input('secondnumber');

    $response = $this->ChildController->Calculation($firstNumber, $operator, $secondnumber);
    return $response;
    }
    }