Skip to content

Instantly share code, notes, and snippets.

@maxca
Last active October 25, 2016 07:08
Show Gist options
  • Select an option

  • Save maxca/971fa447a8cdb725f530847605ddee13 to your computer and use it in GitHub Desktop.

Select an option

Save maxca/971fa447a8cdb725f530847605ddee13 to your computer and use it in GitHub Desktop.
<?php namespace App\Http\Controllers\;
use App\Http\Controllers\FrontendController;
/** alias name servicePackageInterface as packge **/
use App\Repositories\Interfaces\servicePackageInterface as packge;
use App\Repositories\Storage\servicePackageRepository as packageRepository;
class PackageController extends FrontendController
{
private $packge;
private $packageRepository;
/** typing hiting packageRepository **/
public function __construct(packageRepository $packageRepository)
{
parent::__construct();
/** dependency injection **/
$this->packageRepository = $packageRepository;
}
/**
# package instants of servicePackageInterface
# package id get by uri segment | create by route file
**/
public function Package(packge $packge, $package_id = 0)
{
try {
/** using by helper and passing argument package_id **/
$package = app()->make('App\Repositories\servicePackageRepository',['packge_id' => $packge_id]);
} catch (\Exception $e) {
return \Response::json(['code' => 400, 'line' => $e->getLine(), 'file' => $e->getFile(), 'msg' => $e->getMessage()]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment