本文整理汇总了PHP中compact函数的典型用法代码示例。如果您正苦于以下问题:PHP compact函数的具体用法?PHP compact怎么用?PHP compact使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了compact函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
/**
* Displays a view
*
* @param mixed What page to display
* @return void
* @throws NotFoundException When the view file could not be found
* or MissingViewException in debug mode.
*/
public function display()
{
$path = func_get_args();
//debug($path);
$count = count($path);
//debug($count);
if (!$count) {
return $this->redirect('/');
}
$page = $subpage = $title_for_layout = null;
//debug(Inflector::humanize($path[$count - 1]));
if (!empty($path[0])) {
$page = $path[0];
}
if (!empty($path[1])) {
$subpage = $path[1];
}
if (!empty($path[$count - 1])) {
$title_for_layout = Inflector::humanize($path[$count - 1]);
}
$this->set(compact('page', 'subpage', 'title_for_layout'));
//debug($this->render(implode('/', $path)));
//debug($page);
//debug($subpage);
//debug($title_for_layout);
try {
$this->render(implode('/', $path));
} catch (MissingViewException $e) {
if (Configure::read('debug')) {
throw $e;
}
throw new NotFoundException();
}
}
示例2: handle
/**
* Handle the event.
*
* @param ChildWasRegistered $event
* @return void
*/
public function handle(ChildWasRegistered $event)
{
$parent = $event->user;
Mail::send('register.mail.registered', compact('parent'), function ($message) use($parent) {
$message->to($parent->email)->from('hello@shapingyounghearts.org')->subject('Thank you for registering');
});
}
示例3: about
public function about()
{
$first = 'Haonan';
$last = 'Xu';
$people = [];
return view('pages.about', compact('first', 'last', 'people'));
}
示例4: getInstallPath
/**
* Return the install path based on package type.
*
* @param PackageInterface $package
* @param string $frameworkType
* @return string
*/
public function getInstallPath(PackageInterface $package, $frameworkType = '')
{
$type = $this->package->getType();
$prettyName = $this->package->getPrettyName();
if (strpos($prettyName, '/') !== false) {
list($vendor, $name) = explode('/', $prettyName);
} else {
$vendor = '';
$name = $prettyName;
}
$availableVars = $this->inflectPackageVars(compact('name', 'vendor', 'type'));
$extra = $package->getExtra();
if (!empty($extra['installer-name'])) {
$availableVars['name'] = $extra['installer-name'];
}
if ($this->composer->getPackage()) {
$extra = $this->composer->getPackage()->getExtra();
if (!empty($extra['installer-paths'])) {
$customPath = $this->mapCustomInstallPaths($extra['installer-paths'], $prettyName, $type);
if ($customPath !== false) {
return $this->templatePath($customPath, $availableVars);
}
}
}
$packageType = substr($type, strlen($frameworkType) + 1);
$locations = $this->getLocations();
if (!isset($locations[$packageType])) {
throw new \InvalidArgumentException(sprintf('Package type "%s" is not supported', $type));
}
return $this->templatePath($locations[$packageType], $availableVars);
}
示例5: index
/**
* Return an index of archived posts.
*
* @param PostRepositoryInterface $posts
* @param $year
* @param null $month
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index(PostRepositoryInterface $posts, $year, $month = null)
{
$this->dispatch(new AddPostsBreadcrumb());
$this->dispatch(new AddArchiveBreadcrumb());
$posts = $posts->findManyByDate($year, $month);
return view('anomaly.module.posts::archive/index', compact('year', 'month', 'posts'));
}
示例6: index
/**
* index method
*
* @access public
* @return void
*/
public function index()
{
$this->set('testData', 'Some test data');
$test2 = 'more data';
$test3 = 'even more data';
$this->set(compact('test2', 'test3'));
}
示例7: sendEmailConfirmationTo
public function sendEmailConfirmationTo(User $user)
{
$this->to = $user->email;
$this->view = 'emails.confirm';
$this->data = compact('user');
$this->deliver();
}
示例8: index
/**
* Init the index view with the current
* average rate data stored in the db.
*
* @return Response
*/
public function index()
{
// Select the rates of the year 2015.
// NOTE: Just for the purpose of the exercise,
// would be nicer to provide all the results available
// grouped accordingly
$rates = Db::table('monthly_rates')->select('currency_from', 'currency_to', 'month', 'avg_rate')->where('year', 2015)->orderBy('currency_from')->orderBy('currency_to')->get();
// Initialize the messages array as charts.js expects it
if (empty($rates)) {
$messages = [[]];
} else {
$messages = [];
}
$monthRates = [];
$totRates = count($rates);
// Aggregate the messages as an array
// currencyfrom_currencyto => [1 => avg_rate, 2 => ...]
// where the inner array index corresponds to a month
for ($i = 0; $i < $totRates; $i++) {
$rate = $rates[$i];
$monthRates[$rate->month] = $rate->avg_rate;
if ($i == $totRates - 1) {
$key = $rate->currency_from . '-' . $rate->currency_to;
$messages[$key] = $monthRates;
} elseif ($rate->currency_from != $rates[$i + 1]->currency_from || $rate->currency_to != $rates[$i + 1]->currency_to) {
// Build the array key and store the data
$key = $rate->currency_from . '-' . $rate->currency_to;
$messages[$key] = $monthRates;
$monthRates = [];
}
}
return view('socket', compact('messages'));
}
示例9: actionProject
public function actionProject()
{
$form = "";
if (Yii::app()->getRequest()->ispostRequest) {
$project_des = Yii::app()->request->getParam('project_des');
$project_price = Yii::app()->request->getParam('project_price');
$project_name = Yii::app()->request->getParam('project_name');
$project_type = Yii::app()->request->getParam('project_type');
$project_time = Yii::app()->request->getParam('project_time');
if ($project_des != '') {
Yii::app()->session['project_des'] = Yii::app()->request->getParam('project_des');
}
if ($project_name != '') {
Yii::app()->session['project_name'] = Yii::app()->request->getParam('project_name');
}
if ($project_price != '') {
Yii::app()->session['project_price'] = Yii::app()->request->getParam('project_price');
}
if ($project_type != '') {
Yii::app()->session['project_type'] = Yii::app()->request->getParam('project_type');
}
if ($project_time != '') {
Yii::app()->session['project_time'] = Yii::app()->request->getParam('project_time');
}
echo 'success!';
}
$this->renderPartial('_project', compact("form"), false, true);
}
示例10: index
public function index(WpApiContract $wp_client)
{
$posts = $wp_client->getPosts();
$posts = json_decode($posts);
//dd($posts);
return view('layouts.index', compact('posts'));
}
示例11: index
/**
* Display a listing of products on the wishlist.
*
* @return \Illuminate\View\View
*/
public function index()
{
$wishlist = $this->wishlist;
$items = $this->wishlist->items();
$total = $this->wishlist->total();
return View::make('cart.wishlist', compact('wishlist', 'items', 'total'));
}
示例12: pending_leads_by_source
public function pending_leads_by_source()
{
$data_sources = $this->reporting->pendingLeadsBySource()->lists('label');
$data_count = $this->reporting->pendingLeadsBySource()->lists('data');
$leads = $this->reporting->allPendingBySource();
return view('admin.leadrouter.pending_leads_by_source', compact('leads', 'data_sources', 'data_count'));
}
示例13: demo
public function demo()
{
$data = [];
$data['username'] = 'Asna';
$data['password'] = 'family';
return view('page.demo', compact('data'));
}
示例14: index
/**
* index method
*
* @return void
* @access public
*/
public function index($type = null, $lat = null, $long = null, $opt1 = null, $opt2 = null)
{
$params = array('limit' => 35, 'page' => 1);
if (!empty($type) && !empty($lat) && !empty($long)) {
$lat = floatval($lat);
$long = floatval($long);
$opt1 = floatval($opt1);
$opt2 = floatval($opt2);
switch ($type) {
case 'near':
if (!empty($opt1)) {
$cond = array('loc' => array('$near' => array($lat, $long), '$maxDistance' => $opt1));
} else {
$cond = array('loc' => array('$near' => array($lat, $long)));
}
break;
case 'box':
$lowerLeft = array($lat, $long);
$upperRight = array($opt1, $opt2);
$cond = array('loc' => array('$within' => array('$box' => array($lowerLeft, $upperRight))));
break;
case 'circle':
$center = array($lat, $long);
$radius = $opt1;
$cond = array('loc' => array('$within' => array('$center' => array($center, $radius))));
break;
}
$params['conditions'] = $cond;
} else {
$params['order'] = array('_id' => -1);
}
$results = $this->Geo->find('all', $params);
$this->set(compact('results'));
}
示例15: getIndex
public function getIndex()
{
$title = 'Search';
$company_results = Company::select('companies.*', 'c.name as country', 'a.city as city')->join('adresses as a', 'companies.address_id', '=', 'a.id')->join('countries as c', 'a.country_id', '=', 'c.id')->orderBy('companies.id', 'DESC')->take(5)->get();
$company_data = [];
foreach ($company_results as $curr_company) {
$curr_company = (object) ['DT_RowId' => $curr_company->id, 'name' => $curr_company->name, 'references' => $curr_company->references, 'country' => $curr_company->country, 'city' => $curr_company->city];
$curr_entry = (object) $curr_company;
$company_data[] = $curr_entry;
}
$company_init = json_encode(['data' => $company_data]);
$venue_results = Venue::select('venues.*', 'c.name as country', 'a.city as city')->join('adresses as a', 'venues.address_id', '=', 'a.id')->join('countries as c', 'a.country_id', '=', 'c.id')->orderBy('venues.id', 'DESC')->take(5)->get();
$venue_data = [];
foreach ($venue_results as $curr_venue) {
$curr_venue = (object) ['DT_RowId' => $curr_venue->id, 'name' => $curr_venue->name, 'capacity' => $curr_venue->capacity, 'rigging_capacity' => $curr_venue->rigging_capacity, 'country' => $curr_venue->country, 'city' => $curr_venue->city];
$curr_entry = (object) $curr_venue;
$venue_data[] = $curr_entry;
}
$venue_init = json_encode(['data' => $venue_data]);
$contact_results = Contact::select('contacts.*', 'c.name as country')->join('adresses as a', 'contacts.address_id', '=', 'a.id')->join('countries as c', 'a.country_id', '=', 'c.id')->orderBy('contacts.id', 'DESC')->take(5)->get();
$contact_data = [];
foreach ($contact_results as $curr_contact) {
$curr_contact = (object) ['DT_RowId' => $curr_contact->id, 'first_name' => $curr_contact->first_name, 'last_name' => $curr_contact->last_name, 'country' => $curr_contact->country, 'function' => $curr_contact->function];
$curr_entry = (object) $curr_contact;
$contact_data[] = $curr_entry;
}
$contact_init = json_encode(['data' => $contact_data]);
return View::make('site/' . $this->name . '/index', compact('title', 'company_init', 'venue_init', 'contact_init'));
}