小编agh*_*lad的帖子

从角度2中删除存储数组中的项目

我想使用Type Script从角度为2的存储数组中删除一个项目.我正在使用名为Data Service的服务,即DataService代码:

export class DataService{
private data:string[]=[];
addData(msg:string)
{
    this.data.push(msg);
}
getData()
{
    return this.data;
}
deleteMsg(msg:string)
{
    delete[this.data.indexOf(msg)];
}
}
Run Code Online (Sandbox Code Playgroud)

和我的组件类:

 import { Component } from '@angular/core'
 import { LogService } from './log.service'
 import { DataService } from './data.service'
 @Component({
selector:'tests',
template:
`
<div class="container">
    <h2>Testing Component</h2>
    <div class="row">
        <input type="text" placeholder="log meassage" #logo>
        <button class="btn btn-md btn-primary" (click)="logM(logo.value)">log</button>
        <button class="btn btn-md btn-success" (click)="store(logo.value)">store</button>
        <button class="btn btn-md btn-danger" (click)="send()">send</button>
        <button class="btn btn-md " (click)="show()">Show Storage</button>
        <button …
Run Code Online (Sandbox Code Playgroud)

typescript angular

90
推荐指数
7
解决办法
29万
查看次数

在 Laravel 中获取数据库中特定月份的所有记录

在我的数据库中我有这个预订记录

App\Reservation {#2632
     id: 1,
     user_id: 7,
     rest_id: 23,
     reservation_date: "2019-08-29",
     from_time: "16:00:00",
     to_time: "00:00:00",
     count_of_people: 15,
     loyalty_points: 100,
     confirme: 2,
     cancle: 0,
     surveySended: 0,
     surveyAnswer: 0,
     created_at: null,
     updated_at: null,
   },
Run Code Online (Sandbox Code Playgroud)

在我的控制器中,我有以下代码尝试检索本月的所有预订:

public function getRestAdmin(Request $request,$rest_id)
{

$restaurant=Restaurant::find($rest_id);
  $today=\Carbon\Carbon::today();
//reservations made this month
$reservations=$restaurant->reservations()->where('confirme',2)->whereBetween('reservation_date',[$today->startOfMonth(),$today->endOfMonth()])->get();
 }
Run Code Online (Sandbox Code Playgroud)

但我总是变得空!

laravel eloquent php-carbon

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

标签 统计

angular ×1

eloquent ×1

laravel ×1

php-carbon ×1

typescript ×1