l5b-crud
l5b-crud copied to clipboard
Laravel 6 upgrade
Any plan to upgrade this to support the up coming Laravel 6.0?
Well, as you have probably imagined, I've been away from Laravel and this project these last months. I didn't have the time to check or fix the reported issues, not to mention have a peek into Laravel 6. Anyway, this project depends on rappasoft's laravel-boilerplate so while it remains based on 5.8 there will be no need to do it.
laravel-boilerplate is now on version 6
Ops... didn't see that! I checked the github page where it still says it is on 5.8.
Thanks!
I gave the current version a try with 6.x anyway (a fresh Laravel 6.x boiler)
Then
composer require pqrs/l5b-crud
Then
php artisan l5b:crud example
Hit an issue with Str functions as that is now moved as per 5.8 to 6.0 upgrade notes. I then ran:
composer require laravel/helpers
Ran below again and it now works
php artisan l5b:crud example
php artisan migrate
Try to bring up the 'example' route
http://lb2.test/admin/examples
Hit below error. Looks like issue is because I have yet to add any examples items. It is hitting the null returned object and then fails over. This is as much I can get up to. Do we need to add a check here to check for null??
App\Repositories\Backend\ExampleRepository::getActivePaginated :34
...\www\lb2\app\Repositories\Backend\ExampleRepository.php
Line #34 is:
->orderBy($orderBy, $sort)
public function getActivePaginated($paged = 25, $orderBy = 'created_at', $sort = 'desc') : LengthAwarePaginator
{
return $this->model
->orderBy($orderBy, $sort)
->paginate($paged);
}
I have the same problem. I have added a dummy record to the database and it still throws the same error? I can see the record with tinker? Any idea how to solve this as i would really like to use this crud creator.
Okay seems we have have to add a __construct method public function __construct(Example $model) { $this->model = $model; } Cheers John
Thanks @Sgtpsyco23 that works!
Just to be clear. The construct method needs to be added to the app\Repositories\Backend\ExampleRepository.php file
Taking the fix one step further:
modify the file below file
vendor\pqrs\l5b-crud\src\Console\Commands\Stubs\make-repository.stub
and add the construct method to it so it now looks like:
class DummyRepository extends BaseRepository
{
public function __construct(DummyModel $model)
{
$this->model = $model;
}
/**
* @return string
*/
public function model()
{
return DummyModel::class;
}
I will do further testing. Hopefully that is all that is needed!
Can someone explain why previously loading the model in construct was not needed?
Something else to consider is to rename / refactor this to l6crud to reflect the changes or something more generic?
Here goes the next hurdle!
When you try to create a new entry it comes up with below error as the create method does not exist in the base BaseRepository
Symfony\Component\Debug\Exception\FatalThrowableError Call to undefined method App\Repositories\BaseRepository::create()
public function create(array $data) : Example
{
return DB::transaction(function () use ($data) {
===> $example = parent::create([
'title' => $data['title'],
]);
if ($example) {
return $example;
}
throw new GeneralException(__('backend_examples.exceptions.create_error'));
});
}
I've created a pull request that should enable support for the Laravel 6 version of Boilerplate:
#16
I've created a pull request that should enable support for the Laravel 6 version of Boilerplate:
#16
So far looking good. Thanks!
Hello all,
i have a question, since i did't do that so far. How is it possible to test the pull request prior to the merge? How to do that with composer? Should i add the commit reference?
"require": { "vendor/package": "dev-master#?????" }
Maybe someone can give me an advice.
@neppoz if you're looking to override a composer repo with a different branch you can add something like this to your composer.json file:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/dividemysky/l5b-crud/"
}
],
"require": {
.....
"pqrs/l5b-crud": "dev-dev-l5bcrud",
....
},
This would use my fork of this project.
Hi,
i used the fork on your project. But i think the error is not only related on your fork. When i create a new CRUD i got this error:
php artisan l5b:crud mynewtable
Symfony\Component\Debug\Exception\FatalThrowableError : Call to undefined function pqrs\L5BCrud\Console\Commands\snake_case()
So i gave it a quick try and included the Helper in L5BCrud.php. use Illuminate\Support\Str;
Then i replaced the strings with Str::
Afterwords it worked. Any ideas ?
Afterwords it worked. Any ideas ?
Refer to my post above. In short you need laravel/helpers due to changes in Laravel 6
composer require laravel/helpers
Ok, missed that info. Thank you
Here goes the next hurdle!
When you try to create a new entry it comes up with below error as the create method does not exist in the base BaseRepository
Symfony\Component\Debug\Exception\FatalThrowableError Call to undefined method App\Repositories\BaseRepository::create()
public function create(array $data) : Example { return DB::transaction(function () use ($data) { ===> $example = parent::create([ 'title' => $data['title'], ]); if ($example) { return $example; } throw new GeneralException(__('backend_examples.exceptions.create_error')); }); }
Check this link: https://github.com/rappasoft/laravel-boilerplate/issues/1284#issuecomment-544791570
Here goes the next hurdle! When you try to create a new entry it comes up with below error as the create method does not exist in the base BaseRepository
Symfony\Component\Debug\Exception\FatalThrowableError Call to undefined method App\Repositories\BaseRepository::create()
public function create(array $data) : Example { return DB::transaction(function () use ($data) { ===> $example = parent::create([ 'title' => $data['title'], ]); if ($example) { return $example; } throw new GeneralException(__('backend_examples.exceptions.create_error')); }); }
Check this link: rappasoft/laravel-boilerplate#1284 (comment)
Refer to above. This has been solved!