Im using grocery crud 1.5.7.
Im using it without problems for some time.
This is my code:
$crud = new grocery_CRUD();
$crud->set_subject('Detalle Oferta');
$crud->set_table('oferta_detalle');
$crud->columns('id_oferta','id_articulo','cantidad');
$crud->add_fields('id_oferta','id_articulo','cantidad');
$crud->edit_fields('id_oferta','id_articulo','cantidad');
$crud->required_fields('id_oferta','id_articulo','cantidad');
$crud->unset_delete();
$crud->field_type('cantidad', 'integer');
$crud->display_as('id_oferta','Nro. Oferta');
$crud->display_as('id_articulo','Articulo');
$crud->set_relation('id_articulo','articulo','descripcion');
$crud->set_relation('id_oferta','oferta','{id_oferta} - {fecha_vencimiento}');
$output = $crud->render();
$this->_example_output($output);
The insert is completed in database but the result on screen is:
{"success":true,"insert_primary_key":7,"success_message":"
Sus datos han sido guardados correctamente. Editar Detalle Oferta</a> o Volver a la lista</a></p>","success_list_url":"http://compras.esamap.info/site/index.php/proveedores/detalle_ofertas/index/success/7"}
When I don use set_relation I dont get error, but I need set_relation ...
Anyone can help me?
Thanks a lot.
I have reinstalled grocery crud and codeigniter and worked fine.
I think was an incompatibility of versions.
Thanks a lot!
Related
This is the default laravel notifications data field
{
"type":"Update Appointment",
"appointment_id":"379",
"date":null,
"updated_by":"Mahir",
"status":"2"
}
In controller i want to get all notifications with status = 2 and mark as read
Laravel 5.3 doc shows
$user = App\User::find(1);
foreach ($user->unreadNotifications as $notification) {
$notification->markAsRead();
}
How do i modify this to get all notifications with status = 2
Update : looking for something like this
$noti = $user->unreadNotifications->where('data->status',"2");
Note : my database doesn't support json data type.
According to laravel 5.6: JSON Where Clauses
and work with MySQL 5.7
I hope this answer help you
I think, you can create your own channel, (see also Illuminate\Notifications\Channels\DatabaseChannel), where you can override send() method, for saving your notifications. Before that, you can write your migration to update "notifications" table to add your custom filtering field.
See: https://laravel.com/docs/5.5/notifications#custom-channels
Sorry for my English. Hope, you'll understand.
$user = $user->unreadNotifications->where('data.complaint_id',1);
Its work fine for me, I hope it's helpful for you.
I have a website built in Laravel 5.2 that supports multiple languages. Most of the website contents are coming from MySQL database. I cache most of my queries. Example:
$categories = Cache::remember('Categories', 1440, function()
{
return $this->category->getAllOrderByRank();
});
The problem is when I visit the English version of the website the query results get saved. Then when I change the language to Deutsch, The query is still cached and showing the English data from database. Do you guys have any suggestions of how I can handle this?
Thank you
I'd include the locale in the cache name:
$locale = App::getLocale();
$categories = Cache::remember('Categories.' . $locale, 1440, function()
{
return $this->category->getAllOrderByRank();
});
That way if you're set to en you'll pull Categories.en query, if you're set to de you'll get Categories.de, etc.
I'm wondering, though, where are you doing the translations? This probably shouldn't be affected by a cached query.
I get results with join query but in view when I want to show it, it says: trying to get property of non object. I am working over a simple blogging system and I am trying to get blogs from following friends. Here is my view:
#foreach($blogposts as $posts)
<h4>{{ $posts->title }}</h4>
#endforeach
I am sure the problem is at view but I added my controller too, maybe needed and here is my controller:
$posts=DB::table('following')
->join('page_posts', 'following.p_id', '=', 'page_posts.p_id')
->select('page_posts.*')
->where('u_id','=',Auth::User()->id)
->orderBy('updated_at','desc')
->get();
return View::make('index')->with('blogposts',$posts);
Help me with this please.
Try this. You need to pass the values as like this.
return View::make('index',array('blogposts'=>$posts));
I should have used eloquent to solve this means that my controller should be like this:
$posts=following::join('page_posts', 'following.p_id', '=', 'page_posts.p_id')
->select('page_posts.*')
->where('u_id','=',Auth::User()->id)
->orderBy('updated_at','desc')
->get();
return View::make('index')->with('blogposts',$posts);
The problem solved. I posted the answer, because someone else maybe needs.
In my controller, I am calling a model function with the following:
$this->sales_model->softdelete_order($this->input->post('ordernumber'));
what I want to do, in my model is
update Customer_Order_Summary set Deleted='1' where CustomerOrderID='123'
where 123 is $this->input->post('ordernumber')
My Model syntax is:
function softdelete_order($q){
$this->db->set('Deleted','1');
$this->db->where('CustomerOrderID', $q);
$query = $this->db->update('Customer_Order_Summary');
}
This is not working or outputting any errors.
The model is preloaded and the post information is posting and echoing correctly so purely a model syntax issue I think.
Help appreciated as always.
Thanks,
After
$query = $this->db->update('Customer_Order_Summary');
add
$this->db->last_query();
to see your query and you can repair it from there.
Try using
$this->db->set('Deleted',1);
If not working post your exact error
Pardon for my beginner in object oriented PHP Codeigniter. I am confused about using $this->subquery->defaultDB() in https://github.com/NTICompass/CodeIgniter-Subqueries?
$db2 = $this->load->database('db2', TRUE);
$this->load->library('Subquery');
$this->subquery->defaultDB($db2)
$sub = $this->subquery->start_subquery('select');
$sub->select('number')->from('numbers')->where('numberID', 2);
$this->subquery->end_subquery('number');
$query = $db2->get('mytable');
but the subquery still use the default database not db2. Am I doing something wrong? Thank you.
I have created issue to its repository and the author said he will fix it on a few days.
If you are in a rush using this code, I have an alternative. I add forth param defaultDB to be used in subquery. Hope it helps. Cheers!
function start_subquery($statement, $join_type='', $join_on=1, $defaultDB=''){
$db = $this->CI->load->database($defaultDB, true);
$this->dbStack[] = $db;
$this->statement[] = $statement;
if(strtolower($statement) == 'join'){
$this->join_type[] = $join_type;
$this->join_on[] = $join_on;
}
return $db;
}