Created
June 21, 2017 00:55
-
-
Save farukyildiz/a408823cb5c237347cf7f390b79a3ec1 to your computer and use it in GitHub Desktop.
Call Controller Function From Another Controller (Laravel Framework)
This file contains 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
/* **************************************************** */ | |
/* ***************** First Controller ***************** */ | |
/* **************************************************** */ | |
<?php | |
namespace App\Http\Controllers; | |
use Illuminate\Http\Request; | |
use App\Http\Requests; | |
use App\Http\Controllers\Controller; | |
class FunctionController extends Controller | |
{ | |
public function CallThisFunction($String){ | |
echo $String; | |
} | |
} | |
trait PassData_CallThisFunction { | |
public function PassData($String) { | |
parent::CallThisFunction($String); | |
} | |
} | |
?> | |
/* ***************************************************** */ | |
/* ***************** Second Controller ***************** */ | |
/* ***************************************************** */ | |
<?php | |
namespace App\Http\Controllers; | |
use Illuminate\Http\Request; | |
use App\Http\Requests; | |
use App\Http\Controllers\Controller; | |
use App\Http\Controllers\Cms\Helper\FunctionController; | |
class CallClass extends FunctionController { | |
use PassData; | |
} | |
class FromThisController extends Controller | |
{ | |
public function Index(){ | |
$FunctionController = new CallClass(); | |
$ReturnString = $FunctionController->PassData('Data...'); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment