When I add new category to my database it insert fine. But the Codeigniter Database Query Cache does not update when add or remove
Question: Once I add a new category or delete a category how to make sure the codeigniter database cache query gets updated correct
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'community',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => TRUE,
'cachedir' => APPPATH . 'cache/database/',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
Forum Model
public function getcategories() {
$this->db->cache_on(); // Cache On
$query = $this->db->select('*')
->order_by('name', 'asc')
->from('forum')
->get();
if ($query->num_rows() > 0) {
return $query->result_array();
} else {
return array();
}
}
public function add() {
$this->db->trans_start();
$this->db->trans_strict(FALSE);
$insert = array(
'name' => $this->input->post('title'),
'type' => $this->input->post('type'),
'pid' => $this->input->post('pid')
);
$this->db->insert($this->db->dbprefix . 'forum', $insert);
$this->db->trans_complete();
if ($this->db->trans_status() === FALSE) {
$this->db->trans_rollback();
return FALSE;
} else {
$this->db->trans_commit();
return TRUE;
}
}
public function categories_for_deletion($fid) {
$this->db->where('fid', $fid);
$this->db->or_where('pid', $fid);
$query = $this->db->delete('forum');
$this->db->cache_delete('admin', 'category');
if ($query) {
return TRUE;
} else {
return FALSE;
}
}
Controller
<?php
class Category extends MX_Controller {
public function __construct() {
parent::__construct();
$this->load->library('form_validation');
$this->load->library('forum');
$this->load->model('admin/forum/forum_model');
}
public function add() {
$this->form_validation->set_rules('title', 'title', 'required');
if ($this->form_validation->run() == TRUE) {
$this->forum_model->add();
redirect('admin/category');
}
$data['header'] = Modules::run('admin/common/header/index');
$data['footer'] = Modules::run('admin/common/footer/index');
$data['categories'] = $this->forum->generate_select();
$this->load->view('template/forums/category_add_view', $data);
}
public function edit($fid) {
$this->form_validation->set_rules('title', 'title', 'required');
if ($this->form_validation->run() == TRUE) {
}
$data['header'] = Modules::run('admin/common/header/index');
$data['footer'] = Modules::run('admin/common/footer/index');
$this->load->view('template/forums/category_edit_view', $data);
}
public function delete($fid) {
$delete = $this->forum_model->categories_for_deletion($fid);
if ($delete == TRUE) {
redirect('admin/category');
}
$this->index();
}
public function index() {
$data['categories'] = '';
if ($this->forum_model->getcategories()) {
$data['categories'] = $this->forum->set_categories_list($this->forum_model->getcategories());
}
$data['header'] = Modules::run('admin/common/header/index');
$data['navbar'] = Modules::run('admin/common/navbar/index');
$data['footer'] = Modules::run('admin/common/footer/index');
$this->load->view('template/forums/category_view', $data);
}
}
As kishor10d said, the queries will neither update, nor expire automatically or after any duration. You'll have to do it manually, but it doesn't require a cron job or anything. Codeigniter has a method for it.
After every update, you have to do a
$this->db->cache_delete('controller', 'method');
If you don't pass any parameters, it uses current URI to delete associated cache. When your query completes, the cache will be added again giving an effect of an update.
Reference: $this->db->cache_delete() on CodeIgniter Documentation
Related
I am using Laravel-8 and Maatwebsite-3.1 package to import Excel into the DB using Laravel API as the endpoint.
Trait:
trait ApiResponse {
public
function coreResponse($message, $data = null, $statusCode, $isSuccess = true) {
if (!$message) return response() - > json(['message' => 'Message is required'], 500);
// Send the response
if ($isSuccess) {
return response() - > json([
'message' => $message,
'error' => false,
'code' => $statusCode,
'results' => $data
], $statusCode);
} else {
return response() - > json([
'message' => $message,
'error' => true,
'code' => $statusCode,
], $statusCode);
}
}
public
function success($message, $data, $statusCode = 200) {
return $this - > coreResponse($message, $data, $statusCode);
}
public
function error($message, $statusCode = 500) {
return $this - > coreResponse($message, null, $statusCode, false);
}
}
Import:
class EmployeeImport extends DefaultValueBinder implements OnEachRow, WithStartRow, SkipsOnError, WithValidation, SkipsOnFailure
{
use Importable, SkipsErrors, SkipsFailures;
public function onRow(Row $row)
{
$rowIndex = $row->getIndex();
if($rowIndex >= 1000)
return; // Not more than 1000 rows at a time
$row = $row->toArray();
$employee = Employee::create([
'first_name' => $row[0],
'other_name' => $row[1] ?? '',
'last_name' => $row[2],
'email' => preg_replace('/\s+/', '', strtolower($row[3])),
'created_at' => date("Y-m-d H:i:s"),
'created_by' => Auth::user()->id,
]);
public function startRow(): int
{
return 2;
}
}
Controller:
public function importEmployee(Request $request)
{
try {
$validator = Validator::make($request->all(), [
'document' => 'file|mimes:xls,xlsx|max:5000',
]);
if ($request->hasFile('document'))
{
if($validator->passes()) {
$import = new EmployeeImport;
$file = $request->file('document');
$file->move(public_path('storage/file_imports/employee_imports'), $file->getClientOriginalName());
Excel::import($import, public_path('storage/file_imports/employee_imports/' . $file->getClientOriginalName() ));
foreach ($import->failures() as $failure) {
$importerror = new ImportError();
$importerror->data_row = $failure->row(); // row that went wrong
$importerror->data_attribute = $failure->attribute(); // either heading key (if using heading row concern) or column index
$importerror->data_errors = $failure->errors()[0]; // Actual error messages from Laravel validator
$importerror->data_values = json_encode($failure->values());
$importerror->created_by = Auth::user()->id;
$importerror->created_at = date("Y-m-d H:i:s");
$importerror->save();
}
return $this->success('Employees Successfully Imported.', [
'file' => $file
]);
}else{
return $this->error($validator->errors(), 422);
}
}
} catch(\Throwable $e) {
Log::error($e);
return $this->error($e->getMessage(), $e->getCode());
}
}
I made it to SkipOnError and SkipOnFailure.
If there's error, it saves the error into the DB. This is working.
However, there is issue, if some rows fail it still display success (Employees Successfully Imported) based on this:
return $this->success('Employees Successfully Imported.
When there is partial upload, or all the rows or some of the rows have issues, I want to display this to the user. So that it will be interactive.
How do I achieve this?
Thanks
I'm trying to update an item that could have an image or change the one that is already there, when I only change the image or add one it doesn't update, but if I change or add an image along with something else like the name or description then it does update both things. I'm not sure why this is happening.
I'm sending it to the controller like this
submit(item) {
let data = new FormData();
data.append('file', this.imagen);
data.append('name', this.ruleForm.name);
data.append('summary', this.ruleForm.summary);
data.append('description', this.ruleForm.description);
data.append('price', this.ruleForm.price);
data.append('hours', this.ruleForm.hours);
data.append('min_grade', this.ruleForm.min_grade);
data.append('matery', this.matery);
data.append('remover', this.remover);
data.append('strict', this.strict);
this.$refs.ruleForm.validate((valid) => {
if (valid) {
this.loading = true;
this.$inertia.post('/courses/' + item.id, data)
.then(
() => {
this.$message({
type: 'success',
message: 'Guardado correctamente.'
});
this.loading = false
},
(res) => {
this.$message.error(parseError(res)[0]);
this.loading = false;
})
} else {
return false;
}
});
},
This is the full update function in the controller
public function update(CourseSaveRequest $request, $id)
{
Log::info($request);
$editCourse = Course::find($id);
$editCourse->name = $request->name;
$editCourse->summary = $request->summary;
$editCourse->description = $request->description;
$editCourse->price = $request->price;
$editCourse->hours = $request->hours;
$editCourse->min_grade = $request->min_grade;
if ($request->hasFile('file')) {
$this->removeImage($editCourse);
$image = $request->file('file');
$imageName = Uuid::generate(4)->string . '.' . $image->getClientOriginalExtension();
$editCourse->image = '/' . 'img/courses' . '/' . $imageName;
$request->file('file')->move('img/courses', $imageName);
}
$editCourse->save();
return back();
}
private function removeImage(Course $course){
if (!empty($course->image) && file_exists(public_path($course->image))) {
unlink(public_path($course->image));
}
}
Not sure if this is relevant but this is the CourseSaveRequest
public function rules()
{
$rules = [
'name' => 'required|unique:courses',
'summary' => 'required',
'price' => 'required|numeric|min:0',
'hours' => 'required|numeric|min:0',
'min_grade' => 'required|numeric|min:0'
];
if ($this->has('id')) {
$rules['name'] .= ',id,'.$this->get('id');
}
return $rules;
}
I suspect it's the unique rule on the name, you can ignore the current model instance on unique with the following
use Illuminate\Validation\Rule;
...
public function rules()
{
$rules = [
'name' => [
'required',
Rule::unique('courses')->ignore($this->id)
],
'summary' => 'required',
'price' => 'required|numeric|min:0',
'hours' => 'required|numeric|min:0',
'min_grade' => 'required|numeric|min:0'
];
return $rules;
}
I am using codeigniter transaction. i wrote a function but it is not working.It was supposed to complete the transaction while submitting my form. Now its not saving with this code.with out transition code it is working. how can i fix this:
public function twotable_insertData() {
$this->db->trans_start();
$data = array(
'brand_name' => $this->input->post('f_name'),
'brand_user_name' => $this->input->post('l_name'),
);
$brand_id = $this->m_common->insert_row('brands', $data);
echo '$brand_id';
$data1 = array(
'brand_id' => $brand_id,
'stadium_id' => $this->input->post('stadium'),
'concession_stand_no' => $this->input->post('con_std_no'),
);
$this->m_common->insert_row('concession_stands', $data1);
redirect('backend/brand/view_brand');
if ($this->db->trans_status() === FALSE) {
$this->db->trans_rollback();
} else {
echo $this->db->trans_complete();
}
}
I have updated your query...
$this->db->trans_start();
$data = array(
'brand_name' => $this->input->post('f_name'),
'brand_user_name' => $this->input->post('l_name')
);
$brand_id = $this->m_common->insert_row('brands', $data);
// echo '$brand_id';
$data1 = array(
'brand_id' => $brand_id,
'stadium_id' => $this->input->post('stadium'),
'concession_stand_no' => $this->input->post('con_std_no')
);
$this->m_common->insert_row('concession_stands', $data1);
$this->db->trans_complete();
if($this->db->trans_status() === FALSE){
// Check if transaction result successful
$this->db->trans_rollback();
$this->session->set_flashdata('failure', 'Transaction Fails.');
}else{
$this->db->trans_complete();
$this->session->set_flashdata('success', 'Transaction Success.');
}
redirect('backend/brand/view_brand');
I have a warehouse grid in my module. My warehouse contains a lot of products, so when i am going to edit the warehouse, i added a products grid in warehouse edit tab. But, i confused about how to save the entire products grid to database. Really need help.
Here is my Grid
public function __construct() {
parent::__construct();
$this->setId('UnicornInventoryGrid');
$this->setDefaultSort('id_warehouse');
$this->setDefaultDir('ASC');
$this->setSaveParametersInSession(true);
$this->setUseAjax(true);
}
protected function _prepareCollection() {
$collection = Mage::getModel('inventory/warehouse')->getCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns() {
$this->addColumn('id_warehouse', array(
'header' => Mage::helper('inventory')->__('id_warehouse'),
'filter_index' => 'main_table.id_warehouse',
'index' => 'id_warehouse',
'width' => '5px',
));
$this->addColumn('warehouse_name', array(
'header' => Mage::helper('inventory')->__('Warehouse Name'),
'filter_index' => 'main_table.warehouse_name',
'index' => 'warehouse_name',
'editable' => 'TRUE',
'width' => '5px',
));
$this->addColumn('created_by', array(
'header' => Mage::helper('inventory')->__('Created By'),
'filter_index' => 'main_table.created_by',
'index' => 'created_by',
'width' => '5px',
'editable' => 'TRUE',
));
$this->addColumn('manager_email', array(
'header' => Mage::helper('inventory')->__('Manager\'s Email'),
'filter_index' => 'main_table.manager_email',
'index' => 'manager_email',
'width' => '5px',
'editable' => 'TRUE',
));
$this->addColumn('phone', array(
'header' => Mage::helper('inventory')->__('Phone'),
'filter_index' => "main_table.phone",
'index' => "phone",
'editable' => 'TRUE',
));
$this->addColumn('street', array(
'header' => Mage::helper('inventory')->__('Street'),
'filter_index' => "ce3.street",
'index' => "street",
'editable' => 'TRUE',
));
$this->addColumn('city', array(
'header' => Mage::helper('inventory')->__('City'),
'filter_index' => 'main_table.city',
'index' => 'city',
'editable' => 'TRUE',
));
$this->addColumn('country', array(
'header' => Mage::helper('inventory')->__('Country'),
'filter_index' => 'main_table.country',
'index' => 'country',
'type' => 'options',
'editable' => 'TRUE',
'options' => array("" => "All Countries" , "Indonesia" => "Indonesia", "US" => "US")
));
$this->addColumn('status', array(
'header' => Mage::helper('inventory')->__('Status'),
'filter_index' => 'main_table.status',
'index' => 'phone',
));
// $this->addColumn('action',
// array(
// 'header' => Mage::helper('inventory')->__('Action'),
// 'width' => '100',
// 'type' => 'action',
// 'getter' => 'getId',
// 'actions' => array(
// array(
// 'caption' => Mage::helper('inventory')->__('Edit'),
// 'url' => array('base'=> '*/*/edit'),
// 'field' => 'id'
// )
// ),
// 'filter' => false,
// 'sortable' => false,
// 'index' => 'stores',
// 'is_system' => true,
// ));
$this->addExportType('*/*/exportCsv', Mage::helper('inventory')->__('CSV'));
$this->addExportType('*/*/exportXml', Mage::helper('inventory')->__('XML'));
return parent::_prepareColumns();
}
protected function _prepareMassaction() {
$this->setMassactionIdField('id');
$this->getMassactionBlock()->setFormFieldName('inventory_warehouse_mass_action');
$this->getMassactionBlock()->addItem('save', array(
'label' => Mage::helper('inventory')->__('Save'),
'url' => $this->getUrl('*/*/massSaveProduct'),
'confirm' => Mage::helper('inventory')->__('Are you sure?')
));
return $this;
}
public function getRowUrl($row) {
return $this->getUrl('*/*/edit', array('id' => $row->getIdWarehouse()));
}
and here is my controller
public function indexAction(){
$this->loadLayout();
$this->renderLayout();
// die("sadfsaf");
}
public function newAction() {
$id = $this->getRequest()->getParam('id');
if(empty($id)) $this->_title($this->__('Admin'))->_title($this->__('Add Warehouse'));
else $this->_title($this->__('Admin'))->_title($this->__('Edit Warehouse'));
$model = Mage::getModel('inventory/warehouse')->load($id);
if ($model->getId() || empty($id)) {
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
if (!empty($data))
$model->setData($data);
Mage::register('warehouse_warehouse_data', $model);
$this->loadLayout();
$this->_setActiveMenu('unicorn_inventory');
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
$this->_addContent($this->getLayout()->createBlock('inventory/adminhtml_warehouse_edit'))
->_addLeft($this->getLayout()->createBlock('inventory/adminhtml_warehouse_edit_tabs'));
$this->renderLayout();
} else {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('inventory')->__('Warehouse does not exist.'));
$this->_redirect('*/*/');
}
}
public function editAction() {
$id = $this->getRequest()->getParam('id');
if(empty($id)) $this->_title($this->__('Admin'))->_title($this->__('Add Warehouse'));
else $this->_title($this->__('Admin'))->_title($this->__('Edit Warehouse'));
$model = Mage::getModel('inventory/warehouse')->load($id);
if ($model->getId() || empty($id)) {
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
if (!empty($data))
$model->setData($data);
Mage::register('inventory_warehouse_data', $model);
$this->loadLayout();
$this->_setActiveMenu('unicorn_warehouse');
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
$this->_addContent($this->getLayout()->createBlock('inventory/adminhtml_warehouse_edit'))
->_addLeft($this->getLayout()->createBlock('inventory/adminhtml_warehouse_edit_tabs'));
$this->renderLayout();
} else {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('inventory')->__('Warehouse does not exist.'));
$this->_redirect('*/*/');
}
}
public function saveAction() {
if ($data = $this->getRequest()->getPost()) {
$model = Mage::getModel('inventory/warehouse');
$model->setData($data)
->setData('id_warehouse' , $this->getRequest()->getParam('id'));
try {
$collection = Mage::getModel('inventory/warehouse')->getCollection();
foreach($collection as $item){
if(($item->getIdWarehouse() == $model->getIdWarehouse()) && ($model->isObjectNew())){
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('inventory')->__("Id '" . $model->getIdWarehouse(). "' already assigned."));
Mage::getSingleton('adminhtml/session')->setFormData($data);
$this->_redirect('*/*/new');
return;
}
}
// echo "<pre>";
// var_dump($data);
// echo "</pre>";
// die();
$model->save();
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('inventory')->__('Warehouse telah disimpan'));
Mage::getSingleton('adminhtml/session')->setFormData(false);
if ($this->getRequest()->getParam('back')) {
$this->_redirect('*/*/edit', array('id' => $model->getId()));
return;
}
if ($this->getRequest()->getParam('backandnew')) {
$this->_redirect('*/*/new');
return;
}
$this->_redirect('*/*/');
return;
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
Mage::getSingleton('adminhtml/session')->setFormData($data);
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
return;
}
}
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('inventory')->__('Unable to find warehouse to save.'));
$this->_redirect('*/*/');
}
/**
* mass save item(s) action
*/
public function massSaveProductAction() {
$dataIds = $this->getRequest()->getParam('inventory_warehouse_mass_action');
if (!is_array($dataIds)) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('inventory')->__('Please select item(s)'));
} else {
try {
foreach ($dataIds as $dataId) {
// $model = Mage::getModel('inventory/wareproduct')->load($dataId);
$model = Mage::getModel('inventory/wareproduct');
$model->delete();
}
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('supplier')->__('Total of %d record(s) were successfully deleted.', count($dataIds)));
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
}
}
$this->_redirect('*/*/index');
}
/**
* export grid item to CSV type
*/
public function exportCsvAction() {
$fileName = 'Unicorn_Inventory.csv';
$content = $this->getLayout()->createBlock('warehouse/adminhtml_warehouse_grid')->getCsv();
$this->_prepareDownloadResponse($fileName, $content);
}
/**
* export grid item to XML type
*/
public function exportXmlAction() {
$fileName = 'warehouse_warehouse.xml';
$content = $this->getLayout()->createBlock('warehouse/adminhtml_warehouse_grid')->getXml();
$this->_prepareDownloadResponse($fileName, $content);
}
public function gridAction()
{
$this->loadLayout();
$this->getResponse()->setBody(
$this->getLayout()->createBlock('inventory/adminhtml_warehouse_edit_tab_product')->toHtml()
);
}
So, what should we do, so every row in the grid can submitted and saved to database. Thx a lot for your attention.
In
massSaveProductAction
exchange the lines
$model = Mage::getModel('inventory/wareproduct');
$model->delete();
with
$model = Mage::getModel('inventory/wareproduct');
$model->setData('your_attribute_code',"YOUR_VALUE");
$model->save();
Answer for second question:
Get a collection of whatever entity type you have...
$collection->addFieldToFilter('YOUR_GRID_ID_FIELD', array('in'=>array($gridIds)))
and you have the collection. Iterate over the collection and do whatever is needed...
2012-08-23T09:39:06+00:00 ERR (3): exception 'Mage_Core_Exception'
with message 'Invalid block type:
Desbest_Brands_Block_Adminhtml_Brand_Edit_Form' in
/home/desbest/public_html/clients/magentofull/app/Mage.php:594
Desbest/Brands/Block/Adminhtml/Brand/Edit.php
<?php
class Desbest_Brands_Block_Adminhtml_Brand_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
{
public function __construct()
{
/*
$this->_objectId = 'id';
$this->_blockGroup = 'brands';
$this->_controller = 'adminhtml_brand';
$this->_mode = 'edit';
parent::__construct();
*/
parent::__construct();
$this->_objectId = 'id';
$this->_blockGroup = 'brands';
$this->_controller = 'adminhtml_brand';
$this->_mode = 'edit';
$this->_addButton('save_and_continue', array(
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
'onclick' => 'saveAndContinueEdit()',
'class' => 'save',
), -100);
$this->_updateButton('save', 'label', Mage::helper('brands')->__('Save Example'));
$this->_formScripts[] = "
function toggleEditor() {
if (tinyMCE.getInstanceById('form_content') == null) {
tinyMCE.execCommand('mceAddControl', false, 'edit_form');
} else {
tinyMCE.execCommand('mceRemoveControl', false, 'edit_form');
}
}
function saveAndContinueEdit(){
editForm.submit($('edit_form').action+'back/edit/');
}
";
}
public function getHeaderText()
{
if (Mage::registry('example_data') && Mage::registry('example_data')->getId())
{
return Mage::helper('brands')->__('Edit Example "%s"', $this->htmlEscape(Mage::registry('example_data')->getName()));
} else {
return Mage::helper('brands')->__('New Example');
}
}
}
Desbest/Brands/Block/Adminhtml/Brand/Form.php
<?php
class Desbest_Brands_Block_Adminhtml_Brand_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
{
protected function _prepareForm()
{
if (Mage::getSingleton('adminhtml/session')->getExampleData())
{
$data = Mage::getSingleton('adminhtml/session')->getExamplelData();
Mage::getSingleton('adminhtml/session')->getExampleData(null);
}
elseif (Mage::registry('example_data'))
{
$data = Mage::registry('example_data')->getData();
}
else
{
$data = array();
}
$form = new Varien_Data_Form(array(
'id' => 'edit_form',
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
'method' => 'post',
'enctype' => 'multipart/form-data',
));
$form->setUseContainer(true);
$this->setForm($form);
$fieldset = $form->addFieldset('example_form', array(
'legend' =>Mage::helper('brands')->__('Example Information')
));
$fieldset->addField('name', 'text', array(
'label' => Mage::helper('brands')->__('Name'),
'class' => 'required-entry',
'required' => true,
'name' => 'name',
'note' => Mage::helper('brands')->__('The name of the example.'),
));
$fieldset->addField('description', 'text', array(
'label' => Mage::helper('brands')->__('Description'),
'class' => 'required-entry',
'required' => true,
'name' => 'description',
));
$fieldset->addField('other', 'text', array(
'label' => Mage::helper('brands')->__('Other'),
'class' => 'required-entry',
'required' => true,
'name' => 'other',
));
$form->setValues($data);
return parent::_prepareForm();
}
}
I still get the same error with this.
<?php
class Desbest_Brands_Block_Adminhtml_Brand_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
{
}
Your class is named:
Desbest_Brands_Block_Adminhtml_Brand_Edit_Form
But it exists in the file location
Desbest/Brands/Block/Adminhtml/Brand/Form.php
You're missing an Edit folder :)