Comments (7)
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.
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.
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.
Can you please share/screenshot of the error page, the code on the view, and your controller@index method?
from simplecrudgenerator.
Screenshot:
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.
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.
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)
- Another documentation change request HOT 3
- [BUG] Foreign key constraint error after artisan migrate on Laravel 5.8 HOT 2
- Error installing browser kit in Laravel 5.8 HOT 2
- installation issue with Laravel 6.2 HOT 5
- Installation failed with Laravel 6.6.0 HOT 9
- Laravel 6 support HOT 1
- Stub Customization for Laravel 7.x HOT 3
- Error install di laravel 5.8 dengan php 7.4 HOT 2
- Generating CRUD wrappers around existing models HOT 5
- Don't override model HOT 12
- Suggestion: don't put translation into app.php, but create separate crud HOT 5
- [PROPOSAL] Generate CRUD Scaffolds with UUID Primary Keys
- Error: Class 'Database\Factories\Entities\Units\UnitFactory' not found HOT 2
- Cannot install when running latest Laravel an php 8.0.14 HOT 3
- stubs contain non- bootstrap css classes HOT 2
- Let's add a strategy for filling data automatically HOT 4
- suggestion: laravel 9 doc to install HOT 1
- Bootstrap 5 Support HOT 2
- Future Laravel 10.X Issue HOT 4
- Generated API tests include reference to 'Vehicle' HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simplecrudgenerator.