我想composer dump-autoload在控制器中运行没有shell命令.
在laravel 4中我使用Artisan::call('dump-autoload');
但是在laravel 5中这个命令不起作用.
我安装了laravel 5.5,当我运行时php artisan migrate告诉我这个错误
[Illuminate\Database\QueryException] SQLSTATE [42000]:语法错误或访问冲突:1071指定密钥太长; 最大密钥长度为767字节(SQ L:alter table
usersadd uniqueusers_email_unique(
我在下面添加了代码 AppServiceProvider.php
public function boot()
{
Schema::defaultStringLength(191); //Solved by increasing StringLength
}
Run Code Online (Sandbox Code Playgroud)
然后告诉我这个错误
[Illuminate\Database\QueryException] SQLSTATE [42000]:语法错误或访问冲突:1067"created_at"的默认值无效(SQL:create table
password_resets(tokenvarchar(191)not null,created_attimestamp not null) de fault字符集utf8mb4 collate utf8mb4_unicode_ci)
我有这样的时间表
$schedule->call(function () {
$mial->getMail(Auth::user()->id);
})->everyMinute();
Run Code Online (Sandbox Code Playgroud)
告诉我这个错误
在Kernel.php第37行:
试图获得非对象的属性
当我运行此命令时再次显示此错误
$schedule->call(function () {
echo Auth::user()->id;
})->everyMinute();
Run Code Online (Sandbox Code Playgroud)
我需要检查身份验证.
我有一个这样的时间表:
<?php
namespace App\Console;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Console\Scheduling\Schedule;
protected function schedule(Schedule $schedule)
{
Artisan::call('queue:work');
}
Run Code Online (Sandbox Code Playgroud)
我在我的 cronjob 上添加了这个:
* * * * * cd /var/www/html/my_script_address && php artisan schedule:run
它是正确的代码吗?我在问,因为每一分钟都在奔跑Artisan::call('queue:work')。
这是最好的方法吗?
如果有给定的变量$i=478,我如何分别实现数字 4、7、8:这样我就可以存储$j=4,$k=7,$l=8在 PHP 中。有功能吗?
我有这样的复选框:
<input {{isset($shop['private_post'])&&$shop['private_post']=='Yes' ? 'checked' : ''}} id="private_post" value="Yes" type="checkbox" name="private_post">
Run Code Online (Sandbox Code Playgroud)
在控制器中:
$shop= shop::find($request['id']);
$shop->update($request->all());
Run Code Online (Sandbox Code Playgroud)
在编辑模式下,当我复选框 true 正常工作但当我取消选中复选框时不起作用。
我动态创建复选框,但无法使用此命令
If(!isset($request['private_post']))
$request['private_post']=0;
$shop= shop::find($request['id']);
$shop->update($request->all());
Run Code Online (Sandbox Code Playgroud) 我是Laravel的初学者.我使用migrate在数据库中创建表,但我不想migrate:rollback更新我的表.
我想在旧数据库中应用更改而不会丢失当前数据.
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password', 60);
$table->rememberToken();
$table->timestamps();
});
}
Run Code Online (Sandbox Code Playgroud)
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('family');
$table->string('email')->unique();
$table->string('password', 60);
$table->rememberToken();
$table->timestamps();
});
}
Run Code Online (Sandbox Code Playgroud) 我的控制器中有这样的 store 方法
public function store()
{
request()->validate(['family'=>'required']);
User::create(request()->all());
return redirect('/users');
}
Run Code Online (Sandbox Code Playgroud)
和这样的测试方法
/** @test */
public function a_user_require_family()
{
$this->withoutExceptionHandling();
$this->post('/users', [])->assertSessionHasErrors('family');
}
Run Code Online (Sandbox Code Playgroud)
它告诉我这个:
1) Tests\Feature\UserTest::a_user_require_family
Illuminate\Validation\ValidationException:给定的数据无效。
我有这样的数组
$test=Array ( [0] => en [1] => fr )
Run Code Online (Sandbox Code Playgroud)
当我使用这个命令
$a=implode(",",$test);
print_r($a);
Run Code Online (Sandbox Code Playgroud)
结果是:
英语,法语
但我想要这个结果
'恩', 'FR'
php ×9
laravel ×6
laravel-5 ×6
laravel-5.2 ×2
mysql ×2
arrays ×1
checkbox ×1
composer-php ×1
implode ×1
laravel-5.1 ×1
migrate ×1
phpunit ×1
rollback ×1
schedule ×1