小编el *_*uta的帖子

Laravel 5中的时间戳(updated_at,created_at)为空

我有一个问题updated_at,created_at在Laravel 5中的字段.

这是我的迁移:

Schema::create('lots', function (Blueprint $table) {
    $table->increments('id');
    $table->integer('lot');
    $table->integer('is_active');
    $table->timestamps();
});
Run Code Online (Sandbox Code Playgroud)

但是,当我插入一些数据到这个表中,updated_at并且created_at字段为空.如何使用当前时间戳自动完成它们?

我插入这样的数据:

\DB::table('admin_lots')->insert([
    'lot' => $request->cycle_lot,
    'is_active' => '1',
]);
Run Code Online (Sandbox Code Playgroud)

谢谢.

laravel laravel-5 laravel-5.2

7
推荐指数
4
解决办法
2万
查看次数

Laravel 5将数据记录到另一个文件中

有没有办法将数据记录到laravel 5中的另一个文件?不是标准的吗?例如,我想使用这样的东西:

Log::info("Some log data", '/path/to/custom/file.log');
Run Code Online (Sandbox Code Playgroud)

或者至少是否有可能根据日志类型划分日志文件.

Log::info("Some log data");
Log::error("Another log data");
Run Code Online (Sandbox Code Playgroud)

这样信息和错误日志将转到不同的日志文件.

谢谢您的帮助.

laravel monolog laravel-5 laravel-5.2

7
推荐指数
1
解决办法
3734
查看次数

Laravel 5 schedule job every 30 seconds

I am using Laravel schedule to run cron jobs.

In my crontab I have added (with correct path to my project):

* * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1
Run Code Online (Sandbox Code Playgroud)

Now my App\Console\Kernel.php looks like:

protected function schedule(Schedule $schedule)
{
        $schedule->command('investments:calculate_interests')->everyMinute();
        $schedule->call('\App\Http\Controllers\UsersController@testEvent')->everyMinute();
}
Run Code Online (Sandbox Code Playgroud)

Using it like that I successfully run jobs every minute. But how I can change it to run them on every 10 or 20 or 30 seconds?

scheduled-tasks laravel laravel-5 laravel-scheduler

2
推荐指数
1
解决办法
1万
查看次数