Giter Site home page Giter Site logo

Comments (8)

Sogl avatar Sogl commented on May 20, 2024 2

Thx...now it works without json_encode.

from laravel-eloquent-flag.

antonkomarev avatar antonkomarev commented on May 20, 2024

You've got an issue in your view file accordingly to the error message. Could you show it?

from laravel-eloquent-flag.

Sogl avatar Sogl commented on May 20, 2024

Blade file index.blade.php:

@extends('layouts.manage')

@section('content')
    <posts-index
        :table-data="{{ $posts }}">
    </posts-index>
@endsection

Vue component index.vue:

<template>
    <fragment>
        <div class="level">
            <div class="level-left">
                <div class="level-item">
                    <h1 class="title">Администрирование постов</h1>
                </div>
            </div>
            <div class="level-right">
                <div class="level-item">
                    <a :href="route('manage.posts.create')" class="button is-link">
                        <b-icon
                            icon="plus">
                        </b-icon>
                        <span>Создать пост</span>
                    </a>
                </div>
            </div>
        </div>

        <div class="columns is-multiline">
            <div class="column">

                <b-table :data="data">

                    <template slot-scope="props">
                        <b-table-column field="title" label="Название">
                            {{ props.row.title }}
                        </b-table-column>

                        <b-table-column field="excerpt" label="Короткое">
                            {{ props.row.excerpt }}
                        </b-table-column>

                        <b-table-column field="status" label="Статус">
                            {{ props.row.status }}
                        </b-table-column>

                        <b-table-column label="Действия">
<!--                            <a class="button is-outlined is-small m-r-5" :href="route('permissions.show', props.row.id)">Просмотр</a><a :href="route('permissions.edit', props.row.id)" class="button is-small is-outlined">Редактирование</a>-->
                        </b-table-column>
                    </template>

                    <template slot="empty">
                        <section class="section">
                            <div class="content has-text-grey has-text-centered">
                                <p>
                                    <b-icon
                                            pack="far"
                                            icon="frown"
                                            size="is-xxlarge">
                                    </b-icon>
                                </p>
                                <p>Ничего нет</p>
                            </div>
                        </section>
                    </template>

                </b-table>

            </div>
        </div>
    </fragment>
</template>

<script>
    export default {
        props: ['tableData'],
        data() {
            return {
                data: this.tableData
            }
        }
    }
</script>

from laravel-eloquent-flag.

antonkomarev avatar antonkomarev commented on May 20, 2024

Your issue not related to this package. You cannot pass objects to Vue components this way:

:table-data="{{ $posts }}"

It awaits a string, but you giving an object to it. Have you tried this way?

:table-data="{{ json_encode($posts) }}"

Or Blade alternative:

:table-data="@json($posts)"

from laravel-eloquent-flag.

Sogl avatar Sogl commented on May 20, 2024

Ok, no error now, but I still can't see my posts... empty table with this line $posts = Post::onlyNotPublished();. Why?

And why basic framework staff works fine without json_encode?

from laravel-eloquent-flag.

antonkomarev avatar antonkomarev commented on May 20, 2024

Ah.... you've applied scope, but not performed an action:

Post::onlyNotPublished()->get();

from laravel-eloquent-flag.

antonkomarev avatar antonkomarev commented on May 20, 2024

Now I see that documentation isn't clear that it's just scopes. You could chain many scopes like:

Post::onlyNotPublished()->withoutNotVerified()->get();

And so on.

from laravel-eloquent-flag.

antonkomarev avatar antonkomarev commented on May 20, 2024

@Sogl thanks for pointing this out. I've updated documentation.

from laravel-eloquent-flag.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.