Closed samuelsen closed 7 years ago
can you post your xxxCrudController contents
Article crud controller:
namespace App\Http\Controllers\Admin;
use Backpack\CRUD\app\Http\Controllers\CrudController;
// VALIDATION: change the requests to match your own file names if you need form validation
use App\Http\Requests\ArticleRequest as StoreRequest;
use App\Http\Requests\ArticleRequest as UpdateRequest;
class ArticleCrudController extends CrudController
{
public function __construct()
{
parent::__construct();
/*
|--------------------------------------------------------------------------
| BASIC CRUD INFORMATION
|--------------------------------------------------------------------------
*/
$this->crud->setModel("App\Models\Article");
$this->crud->setRoute(config('backpack.base.route_prefix', 'admin').'/article');
$this->crud->setEntityNameStrings('article', 'articles');
/*
|--------------------------------------------------------------------------
| COLUMNS AND FIELDS
|--------------------------------------------------------------------------
*/
// ------ CRUD COLUMNS
$this->crud->addColumn([
'name' => 'date',
'label' => 'Date',
'type' => 'date',
]);
$this->crud->addColumn([
'name' => 'status',
'label' => 'Status',
]);
$this->crud->addColumn([
'name' => 'title',
'label' => 'Title',
]);
$this->crud->addColumn([
'name' => 'featured',
'label' => 'Featured',
'type' => 'check',
]);
$this->crud->addColumn([
'label' => 'Category',
'type' => 'select',
'name' => 'category_id',
'entity' => 'category',
'attribute' => 'name',
'model' => "App\Models\Category",
]);
// ------ CRUD FIELDS
$this->crud->addField([ // TEXT
'name' => 'title',
'label' => 'Title',
'type' => 'text',
'placeholder' => 'Your title here',
]);
$this->crud->addField([
'name' => 'slug',
'label' => 'Slug (URL)',
'type' => 'text',
'hint' => 'Will be automatically generated from your title, if left empty.',
// 'disabled' => 'disabled'
]);
$this->crud->addField([ // TEXT
'name' => 'date',
'label' => 'Date',
'type' => 'date',
'value' => date('Y-m-d'),
], 'create');
$this->crud->addField([ // TEXT
'name' => 'date',
'label' => 'Date',
'type' => 'date',
], 'update');
$this->crud->addField([ // WYSIWYG
'name' => 'content',
'label' => 'Content',
'type' => 'ckeditor',
'placeholder' => 'Your textarea text here',
]);
$this->crud->addField([ // Image
'name' => 'image',
'label' => 'Image',
'type' => 'browse',
]);
$this->crud->addField([ // SELECT
'label' => 'Category',
'type' => 'select2',
'name' => 'category_id',
'entity' => 'category',
'attribute' => 'name',
'model' => "App\Models\Category",
]);
$this->crud->addField([ // Select2Multiple = n-n relationship (with pivot table)
'label' => 'Tags',
'type' => 'select2_multiple',
'name' => 'tags', // the method that defines the relationship in your Model
'entity' => 'tags', // the method that defines the relationship in your Model
'attribute' => 'name', // foreign key attribute that is shown to user
'model' => "App\Models\Tag", // foreign key model
'pivot' => true, // on create&update, do you need to add/delete pivot table entries?
]);
$this->crud->addField([ // ENUM
'name' => 'status',
'label' => 'Status',
'type' => 'enum',
]);
$this->crud->addField([ // CHECKBOX
'name' => 'featured',
'label' => 'Featured item',
'type' => 'checkbox',
]);
$this->crud->enableAjaxTable();
}
public function store(StoreRequest $request)
{
return parent::storeCrud();
}
public function update(UpdateRequest $request)
{
return parent::updateCrud();
}
}
place your $this->crud->enableAjaxTable();
under $this->crud->setEntityNameStrings('article', 'articles');
that's how it works with me,
but you can comment all of your columns and fields then replace $this->crud->enableAjaxTable();
with $this->crud->setFromDb();
to check if it works of not
Any javascript errors? @iMokhles 's answer sounds like a good way to debug this.
No errors in the console, and the edit didn't work. And also I can't find there's a user crud? should it be included in the backpack base folder?
So last night I run through all the steps setting up backpack for larval 5.4 so it should be a fresh install.
And the repo for my project: https://github.com/samuelsen/ufrivillig
What happens if you comment out $this->crud->enableAjaxTable();
?
Greate! that solved the articles, bur how a bout the user list? As mentioned I can't see there's a CRUD for the users? Or where should it bee?
UserCrudController
is inside the PermissionManager package and yes, it does use AjaxDataTables by default. But that one definitely doesn't have any issues - just tested it and it should work just fine.
How does the edit does not work? Might give us a hint in what's happening on your system.
So the edit to the newscrud reveals the list of content, so it seems it some problems using ajax
So when the ajax is enabled it gives a server 500, "faild to loud resource"
[Error] Failed to load resource: the server responded with a status of 500 (Internal Server Error) (user, line 0)
and it's the same for articles
I had the same issue with the default UserCrudController
I had to add this protected $table = 'users';
in User's Model class
but I ended by creating Users's Request, Model Controller myself using
php artisan backpack:crud User
also it will be a good start to customize your Users list Table
no change in specifying the table. It's still the same
Hmm... I tried and tried, but can't replicate your issue.
Just fishing here: does a composer update
fix it? We've pushed a number of fixes yesterday, that you might not have gotten.
Also, could you please tell me more about your dev environments? Operating system, apache/nginx, PHP version, MySQL version, Browser?
so no updates through composer update
the system is:
centOS running apache PHP version 7 normal mysql db running InnoDB on the table
Everything worked using Laravel 5.3 but not after updating to 5.4
hi @samuelsen if you didn't find solution till now, i advise you to create User's Model, Request and CrudController by using this command
php artisan backpack:crud User
and edit your web.php route file to add the following
// if you have admin middleware
Route::group([
'prefix' => config('backpack.base.route_prefix', 'admin'),
'middleware' => ['admin'],
'namespace' => 'App\Http\Controllers\Admin'
], function() {
CRUD::resource('/user', 'UserCrudController');
});
// if you don't have admin middleware
Route::group([
'prefix' => config('backpack.base.route_prefix', 'admin'),
'namespace' => 'App\Http\Controllers\Admin'
], function() {
CRUD::resource('/user', 'UserCrudController');
});
so later you can customize this UserCrudController
to add your own functions and other stuffs
or you have to check this example Crud-Example
So I dont want to do this if can solve it without. Because leaving out Ajax generation of the tables removes the possibility to sort the tables by clicking on the headers.
I've done som more testing, and for all CRUDS I get a ERROR 500 from the server. So it doesn't seem like it is possible to reach the resource. I've re installed all dependencies but without any result.
Checking the logs theres one issue always getting logged when accessing CRUD routes (/useres /articles eg. ) and it is the following: production.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Call to undefined method Illuminate\Routing\Route::getUri()'
Googling that message sais that Laravel 5.4 doesen't support $route->getUri()
instead we should use $route->uri()
Is there somewhere in backpack this should be changed?
SOLUTION!
fixing the "getUri" fault in the backpack base template file solved it! Checked the BASE package of backpack and it's been updated there, but don't understand why I didn't get the new template file when I re installed backpack.
Hi @samuelsen ,
Wow, sorry you had to go through so much trouble. Yes, the layout.blade.php
file does not get updated, because it's already published to your app
folder.
Thanks for keeping us up to date. It will definitely save someone a lot of time :-)
Cheers!
No problem, I would recommend putting it in the docs as a upgrade notice if people are going from 5.3 to 5.4 and not doing a complete reinstall (fresh everything) like you did on the laracast generators ;)
So, when navigating to the list of articles and users in my DB the CRUD list is empty. No entries are listed. I can add new stuff, it is stored in the database, but again not listed. Any suggestions to why?