小编Bus*_*erX的帖子

合并两个Laravel系列

与Laravel系列合作,我的头疼.我有两个集合:

    $dt = Carbon::now();
    $days = new Collection([]);

    /**
     * Create a calender month
     */
    for ($day = 1; $day <= $dt->daysInMonth; $day++) {
        $date = Carbon::create($dt->year, $dt->month, $day)->toDateString();
        $days->push(new Timesheet([
            'date' => $date,
        ]));
    }

    /**
     * Get all timesheets for user
     */
    $timesheets = Timesheet::where('user_id', $this->user->id)
        ->get();
Run Code Online (Sandbox Code Playgroud)

\Illuminate\Database\Eloquent\Collection($timesheets)

#attributes: array:5 [?
    "id" => "1"
    "user_id" => "1"
    "date" => "2016-02-22 22:05:01"
    "created_at" => "2016-02-22 22:05:01"
    "updated_at" => "2016-02-22 22:05:01"
  ]
  // ... one or more …
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-5 laravel-collection

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

字符串与 Lua 模式匹配 URI

如何对这些 URI 进行模式匹配?我需要字符串匹配第一个和第二个斜杠 (1) 之间的任何字符或第一个斜杠 (2) 或 (3) 之后出现的任何字符/。

请注意第一个示例中的尾部斜杠。

(1) /resource/_another-resource

(2) /_resource

(3) /

我有uri_resource = uri:match('^%/(.-)%/')它处理示例 1,但如果不存在尾随斜杠,则会失败。

lua lua-patterns

3
推荐指数
1
解决办法
948
查看次数

标签 统计

laravel ×1

laravel-5 ×1

laravel-collection ×1

lua ×1

lua-patterns ×1

php ×1