很快,我正在输入php artisan db:seed
命令.
我得错误了:
[ReflectionException]
类UserTableSeeder不存在
root@dd-desktop:/opt/lampp/htdocs/dd/laravel# php artisan db:seed
在这里,是我的UserTableSeeder.php
和DatabaseSeeder.php
Page
UserTableSeeder.php
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class UserTableSeeder extends Seeder
{
public function run()
{
DB::table('users')->delete();
User::create(array(
'name' => 'Chris Sevilleja',
'username' => 'sevilayha',
'email' => 'chris@scotch.io',
'password' => Hash::make('awesome'),
));
}
}
Run Code Online (Sandbox Code Playgroud)
DatabaseSeeder.php
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//Model::unguard();
Eloquent::unguard(); …
Run Code Online (Sandbox Code Playgroud) 相关页面:http: //marcmurray.net/test_sites/cans/news.php
我一直在尝试在用户提交电子邮件后加载消息确认模式一段时间,但根本无法使其工作.
到目前为止,我已经尝试回显整个脚本,触发脚本,更改URL中的哈希并检查它,这在网站的其他区域有效.
在页面上添加警报和回显文本等功能工作正常,但是当我使用show方法时它不起作用.这让我相信我要么错误地逃避字符,要么误解了模态的工作原理.任何人都可以看到我搞砸了吗?
PHP:
<?php
if(isset($_POST["submit"])) {
// Checking For Blank Fields..
if($_POST["vname"]==""||$_POST["vemail"]==""||$_POST["sub"]==""||$_POST["msg"]==""){
echo "Please fill out everything! We need to know who you are, and why you want to get in touch with us!";}
else
{
// Check if the "Sender's Email" input field is filled out
$email=$_POST['vemail'];
// Sanitize E-mail Address
$email =filter_var($email, FILTER_SANITIZE_EMAIL);
// Validate E-mail Address
$email= filter_var($email, FILTER_VALIDATE_EMAIL);
$emailConfirmed=$_POST['vemail'];
if (!$email){
echo "Don't forget to include your email adress! Otherwise we …
Run Code Online (Sandbox Code Playgroud) 我想要一个具有三个条件的表中的Codeigniter选择查询.
1. wrk_fld_exc = 140
2. wrk_cs_sts = Open
3. wrk_dlvrd_sts = Delivered OR wrk_cl_sts = Success
Run Code Online (Sandbox Code Playgroud)
第三个条件是AND条件包含OR条件.第一和第二是和条件.
以前,我没有使用$model->save()
函数来插入或更新任何数据.我只是createCommand()
用来执行查询,它正在成功运行.但是,我的团队成员要求我避免createCommand()
和使用$model->save();
现在,我开始清理我的代码,问题$model->save();
对我不起作用.我不知道我错在哪里.
UsersController.php(控制器)
<?php
namespace app\modules\users\controllers;
use Yii;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\swiftmailer\Mailer;
use yii\filters\AccessControl;
use yii\web\Response;
use yii\widgets\ActiveForm;
use app\modules\users\models\Users;
use app\controllers\CommonController;
class UsersController extends CommonController
{
.
.
public function actionRegister() {
$model = new Users();
// For Ajax Email Exist Validation
if(Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())){
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($model);
}
else if ($model->load(Yii::$app->request->post())) {
$post = Yii::$app->request->post('Users');
$CheckExistingUser = $model->findOne(['email' => $post['email']]);
// Ok. Email Doesn't …
Run Code Online (Sandbox Code Playgroud) 如何将Yii 1.x版本升级到Yii 2.0最新版本?我正在使用ubuntu OS,Process将我的旧Yii更新为新的Yii发行版2.0?
如何params
在 Yii2 框架中的控制台控制器中获取配置
我尝试下面的代码,但它不起作用
Yii::$app->params['params_1']
Run Code Online (Sandbox Code Playgroud) 成功登录后我去了About Page.没关系.
但是,URL不会更改为About Page.它与登录页面相同,但页面内容为"关于页面".
SiteController.php
public function actionLogin()
{
if (!\Yii::$app->user->isGuest)
{
return $this->goHome();
}
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()))
{
return $this->render('about'); // Here
}
return $this->render('login', [
'model' => $model,
]);
}
Run Code Online (Sandbox Code Playgroud)
网址与http://localhost/myProject/yii/web/index.php?r=site%2Flogin
.相同.它应该是http://localhost/mylawsuit/yii/web/index.php?r=site%2Fabout
那么,登录后如何更改URL.提前致谢.
我有一张活动桌。其中,due date
of event 以datetime
格式存储。但是,由于需求的一些变化,现在我们只需date
要从due date
列中显示(不包括时间)。
事件(表)
id | user_id | description | due_date | is_completed
1 8 My Event1 2016-08-09 19:16:00 0
2 8 My Event2 2016-08-09 19:53:00 0
Run Code Online (Sandbox Code Playgroud)
我想按日期显示所有事件。就像2016-08-09
.
所以,我尝试了这个查询。
$upcoming_events = Events::find()->select(['due_date'])->distinct()
->where(['user_id' => Yii::$app->users->getId(),'is_completed'=> 0 ])
->andWhere(['>=','due_date',date("Y-m-d")])
->orderBy(['due_date'=>'ASC'])->limit(5)->all();
Run Code Online (Sandbox Code Playgroud)
但是,现在 2 个日期被选择为2016-08-09 19:16:00
& 2016-08-09 19:53:00
。因为,日期部分不是从 select 语句中获取的。它显示了 2 次相同的日期。
var_dump($upcoming_events);
[1] => app\Events Object
(
[_attributes:yii\db\BaseActiveRecord:private] => Array
(
[due_date] => 2016-08-09 19:16:00
) …
Run Code Online (Sandbox Code Playgroud) 我在使用 checkboxColumn 获取所有选定值/数据 Yii2 Gridview 时遇到问题。
我只能使用以下代码获取网格中的值之一:
'class' => 'yii\grid\CheckboxColumn',
'checkboxOptions' => function($model, $key, $index, $widget) {
return ['value' => $model['item_id'] ];
},
Run Code Online (Sandbox Code Playgroud)
需要一些关于如何获取网格中的所有值的建议......
这是我的代码代码片段控制器/视图:
控制器:
public function actionBulk(){
$action=Yii::$app->request->post('action');
$selection=(array)Yii::$app->request->post('selection');
print_r($selection);
}
Run Code Online (Sandbox Code Playgroud)
看法:
<?=Html::beginForm(['transjournal/bulk'],'post');?>
<?=GridView::widget([
'dataProvider' => $dataProvider,
'bordered'=>true,
'striped'=>true,
'condensed'=>true,
'hover'=>true,
'export' => false,
'showOnEmpty' => false,
'panel'=>[
'after'=>Html::submitButton('<i class="glyphicon glyphicon-plus"></i> Posted', ['class' => 'btn btn-success']),
],
'columns' => [
[
'class' => 'yii\grid\CheckboxColumn',
'checkboxOptions' => function($model, $key, $index, $widget) {
return ['value' …
Run Code Online (Sandbox Code Playgroud) 我陷入了非常尴尬的境地,在生成 PDF 时,图像在本地环境中显示。但是,不在生产中。使用 mPDF 生成 PDF 时,图像显示为 [X]。
插入$mpdf->showImageErrors = true;
控制器后。
public function actionExportCasesPdf($id) {
.
.
.
.
$mpdf = new \mPDF();
$mpdf->showImageErrors = true;
$mpdf->WriteHTML($output);
$mpdf->Output($fileName, 'D');
}
Run Code Online (Sandbox Code Playgroud)
错误
Mpdf异常
IMAGE 错误 (..17.jpg):解析图像文件时出错 - 图像类型无法识别,并且 GD imagecreate 不支持
甚至,GD库是使用命令安装在服务器上的apt-get install php5-gd
。并且,图像路径也使用正确。
我试图保留图像源。但是,没有运气。
<img src="<?= \yii\helpers\Url::to('@web/images/logo.png', true) ?>" width="100" alt="logo" />
Run Code Online (Sandbox Code Playgroud)
我搜索并尝试了这些链接给出的解决方案。但是,仍然没有运气:
任何帮助/提示/建议都是值得赞赏的。
php ×7
yii2 ×7
artisan ×1
codeigniter ×1
gridview ×1
javascript ×1
jquery ×1
laravel ×1
laravel-5 ×1
mpdf ×1
url-routing ×1
yii ×1
yii2-model ×1