在Laravel中我有一个表设置,我从BaseController中的表中获取了完整的数据,如下所示
public function __construct()
{
// Fetch the Site Settings object
$site_settings = Setting::all();
View::share('site_settings', $site_settings);
}
Run Code Online (Sandbox Code Playgroud)
现在我想访问$ site_settings.在所有其他控制器和视图中,所以我不需要一次又一次地编写相同的代码,所以任何人请告诉我解决方案或任何其他方式,以便我可以从表中获取一次数据并在所有控制器中使用它视图.
我在一个页面上有两个表单:登录表单和注册表单.当我提交注册表单时,它会验证两个:登录和注册的表单字段.如果两个表单具有相同的模型(用户模型),我该如何处理它
注册表格
<?php echo $this->Form->create('User', array('url' => array('controller' => 'users', 'action' => 'add'))); ?>
<?php echo $this->Form->input('username', array('label' => false, 'div' => false, 'class' => 'reg_input'));?>
<?php echo $this->Form->input('email', array('label' => false, 'div' => false, 'class' => 'reg_input'));?>
<?php echo $this->Form->input('password', array('label' => false, 'div' => false, 'class' => 'reg_input'));?>
<?php echo $this->Form->input('confirm_password', array('type' => 'password', 'label' => false, 'div' => false, 'class' => 'reg_input'));?>
<?php echo $this->Form->submit(__('Submit', true), array ('class' => 'reg_button', 'div' => false));
echo $this->Form->end();?>
Run Code Online (Sandbox Code Playgroud)
和登录表单如下
<?php …Run Code Online (Sandbox Code Playgroud) 我有一个表,其中逗号分隔另一个表的id我想在cakephp中以正确的形式使用以下查询与find函数
"select * from special_offers where find_in_set('".$storeId."', stores) and user_id = '". $userId ."'";
Run Code Online (Sandbox Code Playgroud) 我正在使用data-uk-modal打开一个模态框,当我点击按钮时它打开完美但我只是想在页面加载时打开这个,我有以下代码的领带
<button class="md-btn md-btn-success" data-uk-modal="{target:'#my_id'}">Open Dialogue</button>
<div class="uk-modal" id="my_id" >
<div class="uk-modal-dialog">
<div class="uk-modal-header">
Custom Content here
</div>
</div>
<div class="uk-modal-footer uk-text-right">
<button type="button" class="md-btn md-btn-flat uk-modal-close">Close</button>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这是我的js代码
请告诉我如何在页面加载时打开diwlogure框
尝试运行我的控制器时出现以下错误
未找到控制器类
我在我的routes.php文件中有这个代码
Route::get('cms/create-page', 'AdminCMSController@create_page');
Route::post('cms/createpage','AdminCMSController@createpage');
Route::controller('cms','AdminCMSController');
Run Code Online (Sandbox Code Playgroud)
这是我的控制器中的代码
class AdminCMSController extends BaseController {
public function create_page() {
}
public function createpage() {
}
}
Run Code Online (Sandbox Code Playgroud)
我该如何解决?