GithubHelp home page GithubHelp logo

Comments (7)

nafiesl avatar nafiesl commented on June 3, 2024 1

Hehe, you were right, we should mention that on the docs, just to be more explicit. And I will also note your suggestion, the generator should detect the pluralized given model name, and covert it to singular.

You're welcome, yhanks a lot.

from simplecrudgenerator.

nafiesl avatar nafiesl commented on June 3, 2024

I see, about the documentation, i will update the readme as soon as i can, and be more explicit for the package setup on fresh install laravel.

About the undefined fistItem() method problem, in the controller@index method, are you changing paginate() to.get() on the model database query?
Because firstItem() only works on paginated query results.

However, i will simulate to install the package from fresh install laravel 5.7. And get back to you after that, i will see if i found same problem like you did.

from simplecrudgenerator.

Spudley avatar Spudley commented on June 3, 2024

Hi.

About the undefined fistItem() method problem, in the controller@index method, are you changing paginate() to.get() on the model database query?

No, I didn't make any code modifications at all.

The only file I edited at all was the .env file to configure it use sqlite for the DB.

from simplecrudgenerator.

nafiesl avatar nafiesl commented on June 3, 2024

Can you please share/screenshot of the error page, the code on the view, and your controller@index method?

from simplecrudgenerator.

Spudley avatar Spudley commented on June 3, 2024

Screenshot:

screen shot 2018-11-21 at 09 36 46

Code from the view:

@extends('layouts.app')

@section('title', __('form_submissions.list'))

@section('content')
<div class="mb-3">
    <div class="float-right">
        @can('create', new App\FormSubmissions)
            <a href="{{ route('form_submissions.create') }}" class="btn btn-success">{{ __('form_submissions.create') }}</a>
        @endcan
    </div>
    <h1 class="page-title">{{ __('form_submissions.list') }} <small>{{ __('app.total') }} : {{ $formSubmissions->total() }} {{ __('form_submissions.form_submissions') }}</small></h1>
</div>

<div class="row">
    <div class="col-md-12">
        <div class="card">
            <div class="card-header">
                <form method="GET" action="" accept-charset="UTF-8" class="form-inline">
                    <div class="form-group">
                        <label for="q" class="control-label">{{ __('form_submissions.search') }}</label>
                        <input placeholder="{{ __('form_submissions.search_text') }}" name="q" type="text" id="q" class="form-control mx-sm-2" value="{{ request('q') }}">
                    </div>
                    <input type="submit" value="{{ __('form_submissions.search') }}" class="btn btn-secondary">
                    <a href="{{ route('form_submissions.index') }}" class="btn btn-link">{{ __('app.reset') }}</a>
                </form>
            </div>
            <table class="table table-sm table-responsive-sm">
                <thead>
                    <tr>
                        <th class="text-center">{{ __('app.table_no') }}</th>
                        <th>{{ __('form_submissions.name') }}</th>
                        <th>{{ __('form_submissions.description') }}</th>
                        <th class="text-center">{{ __('app.action') }}</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach($formSubmissions as $key => $formSubmissions)
                    <tr>
                        <td class="text-center">{{ $formSubmissions->firstItem() + $key }}</td>
                        <td>{!! $formSubmissions->name_link !!}</td>
                        <td>{{ $formSubmissions->description }}</td>
                        <td class="text-center">
                            @can('view', $formSubmissions)
                                <a href="{{ route('form_submissions.show', $formSubmissions) }}" id="show-form_submissions-{{ $formSubmissions->id }}">{{ __('app.show') }}</a>
                            @endcan
                        </td>
                    </tr>
                    @endforeach
                </tbody>
            </table>
            <div class="card-body">{{ $formSubmissions->appends(Request::except('page'))->render() }}</div>
        </div>
    </div>
</div>
@endsection

Controller@index method:

/**
 * Display a listing of the formSubmissions.
 *
 * @return \Illuminate\View\View
 */
public function index()
{
    $formSubmissionsQuery = FormSubmissions::query();
    $formSubmissionsQuery->where('name', 'like', '%'.request('q').'%');
    $formSubmissions = $formSubmissionsQuery->paginate(25);

    return view('form_submissions.index', compact('formSubmissions'));
}

from simplecrudgenerator.

nafiesl avatar nafiesl commented on June 3, 2024

Oh, i see the problem there. You should use singular name of Model.

Try this command:

php artisan make:crud FormSubmission

instead of

php artisan make:crud FormSubmissions

from simplecrudgenerator.

Spudley avatar Spudley commented on June 3, 2024

Ah! Okay.

And of course, the test I did with crud-simple had a singluar name, which is why it worked.

So I guess the takeaway from all this is something else that needs to be mentioned to the docs. :)

(it could maybe also be handled more gracefully in the generator, but a sentence added to the docs would be a quicker way to fix it for now)

Thanks for your help. :-)

from simplecrudgenerator.

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.