小编Pri*_*hra的帖子

Laravel 命名路线不起作用

最近我切换到 Laravel 5.3。

我有以下路线

Route::get('/activate/token', 'AccountActivationController@activate')->name('auth.activate');
Run Code Online (Sandbox Code Playgroud)

但是,当我使用

dd(route('auth.activate'));
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

UrlGenerator.php 第 314 行中的 InvalidArgumentException:未定义路由 [auth.activate]。

它可以完美地与

Route::get('/activate/token', [
    'as' => 'auth.activate',
    'uses' => 'AccountActivationController@activate',
]);
Run Code Online (Sandbox Code Playgroud)

这是 Laravel 5.3 中的新功能吗?我对 Laravel 本身还很陌生。

谢谢。

php laravel-5

5
推荐指数
1
解决办法
1321
查看次数

模拟 Observable 在 Jest 中抛出错误

我试图模拟Angular的PUT调用HttpClient以抛出错误。我正在使用throwError它。它不起作用。我应该更改什么以使其抛出错误并调用该handleError方法?我正在使用 Jest

it(`should call the 'handleError' method when a request to store data was not successful`, () => {
    const error: HttpErrorResponse = {
      status: 401,
      message: 'You are not logged in',
    } as HttpErrorResponse;

    jest.spyOn(httpClientServiceMock, 'put').mockReturnValue(throwError(error));
    const spy = jest.spyOn(httpService, 'handleError');

    httpService.requestCall('some-url', ApiMethod.PUT, {});
    expect(spy).toBeCalled();
  });
Run Code Online (Sandbox Code Playgroud)

服务文件

  requestCall(url: string, method: ApiMethod, data?: any): Observable<any> {
    const headers = {
      'X-XSRF-TOKEN': this.xsrfToken,
      'Content-Type': 'application/json; charset=UTF-8',
    };

    const requestConfig = { …
Run Code Online (Sandbox Code Playgroud)

observable rxjs jestjs angular angular-jest

5
推荐指数
1
解决办法
3832
查看次数

在Vue js中使用track-by或key in v-for有什么用?

我是javascript和javascript框架世界的新手.什么是实际使用track-by还是keyv-for在Vue公司JS?

我阅读了文档,但并没有真正理解它的用法.

javascript vuejs2

4
推荐指数
1
解决办法
2307
查看次数

JsonParseException:无效的 JSON 输入。位置:9。字符:'.'

我正在将 MongoDB 与Spring Boot 2.0.1.RELEASE. 一切似乎都运行良好。我能够使用 MongoRepository 正确执行 CRUD 操作。当我使用 mongodb 查询时

@Query(value = "{address.city:?0}")
public List<Hotel> findByCity(String city);

@Query(value = "{address.country:?0}")
public List<Hotel> findByCountry(String country);
Run Code Online (Sandbox Code Playgroud)

当我尝试使用 url 访问数据时localhost:8090/hotels/address/city/Rome,我收到以下错误响应

{
    "timestamp": "2018-05-04T04:51:43.549+0000",
    "status": 500,
    "error": "Internal Server Error",
    "message": "Invalid JSON input. Position: 9. Character: '.'.",
    "path": "/hotels/address/city/rome"
}
Run Code Online (Sandbox Code Playgroud)

和以下登录控制台:

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.bson.json.JsonParseException: Invalid JSON input. Position: 9. Character: '.'.] with …
Run Code Online (Sandbox Code Playgroud)

spring mongodb mongorepository spring-boot spring-mongodb

4
推荐指数
1
解决办法
5075
查看次数

HTTP_INTERCEPTORS 仅在 AppModule 中

我正在尝试在我的 Angular 6 应用程序中实现延迟加载,我所有的 http 调用都是在FeatureModule(延迟加载)中进行的,但我仍然必须添加HttpClientModule我的AppModule而不是FeatureModule. 真的不明白为什么。另外,当我在我的 中添加拦截器时FeatureModule,它们没有拦截任何请求。我必须将它添加到AppModule唯一的(我猜,这是因为HttpClientModule在 中AppModule)。

我想明白为什么会这样??为什么我们不能HttpClientModule并且HTTP_INTERCEPTORS只在我没有打电话的地方FeatureModule而不是在AppModule那里http

angular-http-interceptors angular

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

Laravel 电子邮件导致未找到视图错误

我正在触发一个事件,当用户请求重置密码时,该事件会向用户发送电子邮件。

这是将发送电子邮件类 SendResetPasswordLink { 的事件侦听器

    public function handle(UserForgotPassword $event) {
        Mail::to($event->user)
            ->queue(new SendResetPasswordToken($event->user->passwordResetToken));
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的邮件类:

class SendResetPasswordToken extends Mailable {
    use Queueable, SerializesModels;

    public $token;

    public function __construct(PasswordReset $token) {
        $this->token = $token;
    }

    public function build() {
        return $this->subject('Reset your MyEngine password')
                    ->markdown('emails.password.reset')
                    ->text('emails.password.reset_text');
    }
}
Run Code Online (Sandbox Code Playgroud)

我有可用的电子邮件文件(html 和文本)

resources/views/emails/password/reset.blade.php
Run Code Online (Sandbox Code Playgroud)

resources/views/emails/password/reset_text.blade.php
Run Code Online (Sandbox Code Playgroud)

它不起作用,我收到以下错误:

"View [] not found. (View: /home/vagrant/Laravel/youtube/resources/views/emails/password/reset.blade.php)"
Run Code Online (Sandbox Code Playgroud)

我需要做什么?我所有的刀片文件都已就位。

这是我的 reset.blade.php

@component('mail::message')
<strong>Hello {{ $token->user->getFirstNameOrUserName() }}!</strong>

You are receiving this email because we received a password reset request …
Run Code Online (Sandbox Code Playgroud)

laravel laravel-5

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

在 Laravel 中批量更新具有多关系的表

我有一个One to Many relationshipChannel 和 Video 之间的表。两个表都有visibility字段。当我更新频道的可见性时,我想使用频道的可见性值更新属于该频道的所有视频的可见性。

如何在 Laravel 5.4 中实现这种大规模更新功能?

laravel laravel-5 laravel-5.4

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

Angular 6 中的延迟加载导致无法匹配任何路由

我正在尝试在我的 Angular 应用程序中实现延迟加载。这是我的路线:

应用程序路由.module.ts

const routes: Routes = [
  {
    path: '',
    loadChildren: './customer/customer.module#CustomerModule',
    pathMatch: 'full'
  }
];
Run Code Online (Sandbox Code Playgroud)

并在模块中:

  imports: [RouterModule.forRoot(routes)],
Run Code Online (Sandbox Code Playgroud)

客户路由.module.ts

export const routes: Routes = [
  { path: '', component: ComparePageComponent },
  { path: 'funds', component: FundSelectionComponent },
  { path: ':service', component: ComparePageComponent },
  { path: '**', component: PageNotFoundComponent },
];
Run Code Online (Sandbox Code Playgroud)

并在模块中:

imports: [
    RouterModule.forChild(routes)
  ],
Run Code Online (Sandbox Code Playgroud)

现在,我有一个逻辑,/profile当没有路径参数时,即当this._router.navigate(['', 'profile'])我已经在客户模块中定义了路径的 url 为 '' ( )时,将加载页面{ path: ':service', component: ComparePageComponent }

但是,当应用程序运行时,会导致以下错误:

错误错误:未捕获(承诺):错误:无法匹配任何路由。URL 段:“个人资料”错误:无法匹配任何路由。URL 段:ApplyRedirects.push../node_modules/@angular/router/fesm5/router.js.ApplyRedirect 处的“配置文件” …

angular-routing angular

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

ERR_HTTP_HEADERS_SENT:在ServerResponse上将标头发送到客户端后,无法设置标头

我正在尝试使用NodeJS和Express创建一个没有任何数据库的简单REST API。我已将所有数据存储在JSON文件中。数据采用对象数组的形式。

我有类似fund-name /:portId的路径

所以我这样做:

const fundName = require('./json/fund-name.json');

app.get('/fund-details:portId', (req, res) => {

    const portId = req.params.portId;
    fundDetails.forEach(fund => {
        if (fund.portId === portId) {
            return res.json(fund);
        }

        return res.json([]);
    });
});
Run Code Online (Sandbox Code Playgroud)

当我点击url时http:localhost:3000/fund-details/1234,出现以下错误:

错误[ERR_HTTP_HEADERS_SENT]:将标头发送到ServerResponse.header上的ServerResponse.setHeader(_http_outgoing.js:470:11)(/ home / username / Desktop / data-server / node_modules / express / l ib)后,无法设置标头/response.js:767:10)

当我不通过任何路径参数来获取所有资金时,它会很好地工作。我要去哪里错了?

node.js express

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