小编Ash*_*Ash的帖子

Laravel 5.4 Storage :: delete()不起作用(找不到方法删除)

Storage::delete($filepath);在Laravel 5.4中无法正常工作。

我已经搜索了与此问题有关的其他人,但是大多数其他人似乎都犯了错误,该错误提供的文件路径中没有上述内容/,但这不是我的问题。

我正在使用use Illuminate\Support\Facades\Storage;(根据Laravel文档),并且我注意到PHPStorm说中出现错误Method delete not found in Illuminate\Support\Facades\Storage

我的代码看起来像;

<?php

namespace App\Http\Controllers;

...
use Illuminate\Support\Facades\Storage;
// also tried use Storage;
...

public function deleteFile($id)
{
    try {
        $image = Files::where('id', $id)->get()->first();
        Storage::delete($image->filepath);
        return Files::destroy($id);

    } catch ( \Exception $e) {
        return back()->with('alert-warning', 'Something went wrong: ' . $e);
    }
}
Run Code Online (Sandbox Code Playgroud)

我的$ image-> filepath看起来像 /Users/usrname/sites/sitename/storage/app/images/34/o8Aq1T3Hi67sOtuTgBh9P7QWA1Ahj4KH2QBR77n0.png

有人能帮忙吗?

php laravel laravel-5

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

新的换行符Angular 2中的打字稿代码

我有这个代码按预期工作;

import {Component} from 'angular2/core';

@Component({
    selector: 'media-tracker-app',
    templateUrl: 'app/app.component.html',
    styles: ['      h1 {            color: #ffffff;     }']
})

export class AppComponent {}
Run Code Online (Sandbox Code Playgroud)

但是如果我添加一些新的行来使CSS更具可读性:

import {Component} from 'angular2/core';

@Component({
    selector: 'media-tracker-app',
    templateUrl: 'app/app.component.html',
    styles: ['      h1 {            
        color: #ffffff;     
    }']
})

export class AppComponent {}
Run Code Online (Sandbox Code Playgroud)

...然后它破坏了我的代码.

在控制台中我得到:SyntaxError:unterminated string literal

我刚刚开始学习Angular 2 ......任何想法?

angularjs

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

Vue2子组件对象v-for列表渲染的奇怪问题

我有一个包含数组和对象的父组件:

    data() {
        return {
            products: [],
            attributes: {},
        }
    },
Run Code Online (Sandbox Code Playgroud)

当我的父组件被加载时,它获取一些AJAX数据并填充变量:

    mounted() {
        axios.get('/requests/getProducts/' + this.currentCategory).then(response => {
            this.products = response.data;
            this.createAttributes(); // runs some methods to populate the attributes object
        });
    }, 
Run Code Online (Sandbox Code Playgroud)

然后我有一个子组件,我将用它来显示属性.父模板中的代码:

    <search-attributes :attributes="attributes"></search-attributes>
Run Code Online (Sandbox Code Playgroud)

我在我的子组件中声明了道具:

    props: ['attributes'],
Run Code Online (Sandbox Code Playgroud)

到目前为止一切顺利,我可以控制父母和孩子的数据...

问题是当我尝试v-for子组件中的属性时,它只返回任何内容:

/////////////// this does not render anything ///////////////

<template>
    <div>
        <div v-for="(value, key) in attributes">
            {{ key }}
        </div>
    </div>
</template>
Run Code Online (Sandbox Code Playgroud)

但是,如果我将产品和属性变量传递给子组件,并在子组件中呈现产品,属性将开始工作!

/////////////// this works /////////////
<template>
    <div>
        <div v-for="(value, key) in attributes">
            {{ key }}
        </div> …
Run Code Online (Sandbox Code Playgroud)

vue.js vue-component vuejs2

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

标签 统计

angularjs ×1

laravel ×1

laravel-5 ×1

php ×1

vue-component ×1

vue.js ×1

vuejs2 ×1