Reputation: 164
I have this crud controller :
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Requests\HotelRequest;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
/**
* Class HotelCrudController
* @package App\Http\Controllers\Admin
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
*/
class HotelCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
/**
* Configure the CrudPanel object. Apply settings to all operations.
*
* @return void
*/
public function setup()
{
CRUD::setModel(\App\Models\Hotel::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/hotel');
CRUD::setEntityNameStrings('hotel', 'hotels');
}
/**
* Define what happens when the List operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
* @return void
*/
protected function setupListOperation()
{
CRUD::addColumn([
'name' => 'company', // name of relationship method in the model
'type' => 'relationship',
'label' => 'Empresa', // Table column heading
]);
CRUD::addColumn([
'name' => 'name', // name of relationship method in the model
'label' => 'Nombre', // Table column heading
]);
/**
* Columns can be defined using the fluent syntax:
* - CRUD::column('price')->type('number');
*/
}
/**
* Define what happens when the Create operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-create
* @return void
*/
protected function setupCreateOperation()
{
CRUD::setValidation(HotelRequest::class);
//CRUD::setFromDb(); // set fields from db columns.
// section General information
CRUD::field([
'name' => 'company',
'label' => 'Compañía',
'wrapper' => [
'class' => 'form-group col-md-10'
],
])->tab('Información general');
CRUD::field([
'name' => 'enabled',
'type' => 'switch',
'label' => 'Habilitado',
'color' => 'primary',
'wrapper' => [
'class' => 'form-group col-md-2 text-center d-flex align-items-center pt-5'
],
'tab' => 'Información general'
]);
CRUD::field([
'name' => 'internalname',
'type' => 'text',
'label' => 'Nombre interno',
'tab' => 'Información general'
]);
CRUD::field([
'name' => 'logo',
'type' => 'image',
'label' => 'Logo',
'wrapper' => [
'class' => 'form-group col-md-3'
],
'withFiles' => true,
'tab' => 'Información general'
]);
CRUD::field([
'name' => 'stickylogo',
'type' => 'image',
'label' => 'Logo Sticky',
'wrapper' => [
'class' => 'form-group col-md-3'
],
'withFiles' => true,
'tab' => 'Información general'
]);
CRUD::field([
'name' => 'name',
'type' => 'text',
'label' => 'Título',
'wrapper' => [
'class' => 'form-group col-md-6'
],
'tab' => 'Información general'
]);
CRUD::field([
'name' => 'slug',
'type' => 'slug',
'target' => 'name',
'label' => 'Slug',
'wrapper' => [
'class' => 'form-group col-md-6'
],
'attributes' => [
'readonly' => 'readonly'
],
'tab' => 'Información general'
]);
CRUD::field([
'name' => 'email',
'type' => 'email',
'label' => 'Correo electrónico',
'prefix' => '<i class="la la-envelope"></i>',
'wrapper' => [
'class' => 'form-group col-md-6'
],
'tab' => 'Información general'
]);
CRUD::field([
'name' => 'telephone',
'type' => 'phone',
'label' => 'Teléfono',
'wrapper' => [
'class' => 'form-group col-md-6'
],
'config' => [
'initialCountry' => 'es',
'nationalMode' => true,
'autoHideDialCode' => false
],
'tab' => 'Información general'
]);
}
/**
* Define what happens when the Update operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-update
* @return void
*/
protected function setupUpdateOperation()
{
$this->setupCreateOperation();
}
}
When save the form, even without any change, the photos path are deleted from de DB
PHP 8.3.4 (cli) (built: Mar 16 2024 08:40:08) (NTS) Copyright (c) The PHP Group Zend Engine v4.3.4, Copyright (c) Zend Technologies with Zend OPcache v8.3.4, Copyright (c), by Zend Technologies with Xdebug v3.3.1, Copyright (c) 2002-2023, by Derick Rethans
10.45.1.0
backpack/basset: 1.2.4 backpack/crud: 6.6.4 backpack/devtools: 3.0.4 backpack/editable-columns: 3.0.7 backpack/generators: v4.0.3 backpack/pagemanager: 3.3.0 backpack/permissionmanager: 7.2.0 backpack/pro: 2.1.7 backpack/theme-tabler: 1.2.3
Upvotes: 0
Views: 48
Reputation: 775
It seems you have logo
and stickylogo
image fields in the $translatable
array of your model.
Please remove and retry.
Upvotes: 0