Created
June 1, 2020 16:17
-
-
Save infinitbility/042c9c38294be2fd4567dbfe5526ddfe to your computer and use it in GitHub Desktop.
Parent controller for calling function from another controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment