Accessing image property of K2 item - joomla
I'm developing a module that displays a specific number of k2 items based on its category id. I can get those item but I'm not able to access the image on it. When I try $item->image returns the following notice:
Notice: Undefined property: stdClass::$image
Here is the object I get from my sql query:
stdClass Object
(
[id] => 5
[title] => News test item
[alias] => news-test-item
[catid] => 4
[published] => 1
[introtext] => Some intro text
[fulltext] =>
[video] =>
[gallery] =>
[extra_fields] => []
[extra_fields_search] =>
[created] => 2014-03-28 21:42:01
[created_by] => 252
[created_by_alias] =>
[checked_out] => 0
[checked_out_time] => 0000-00-00 00:00:00
[modified] => 0000-00-00 00:00:00
[modified_by] => 0
[publish_up] => 2014-03-28 21:42:01
[publish_down] => 0000-00-00 00:00:00
[trash] => 0
[access] => 1
[ordering] => 1
[featured] => 0
[featured_ordering] => 0
[image_caption] =>
[image_credits] =>
[video_caption] =>
[video_credits] =>
[hits] => 0
[params] => {"catItemTitle":"","catItemTitleLinked":"","catItemFeaturedNotice":"","catItemAuthor":"","catItemDateCreated":"","catItemRating":"","catItemImage":"","catItemIntroText":"","catItemExtraFields":"","catItemHits":"","catItemCategory":"","catItemTags":"","catItemAttachments":"","catItemAttachmentsCounter":"","catItemVideo":"","catItemVideoWidth":"","catItemVideoHeight":"","catItemAudioWidth":"","catItemAudioHeight":"","catItemVideoAutoPlay":"","catItemImageGallery":"","catItemDateModified":"","catItemReadMore":"","catItemCommentsAnchor":"","catItemK2Plugins":"","itemDateCreated":"","itemTitle":"","itemFeaturedNotice":"","itemAuthor":"","itemFontResizer":"","itemPrintButton":"","itemEmailButton":"","itemSocialButton":"","itemVideoAnchor":"","itemImageGalleryAnchor":"","itemCommentsAnchor":"","itemRating":"","itemImage":"","itemImgSize":"","itemImageMainCaption":"","itemImageMainCredits":"","itemIntroText":"","itemFullText":"","itemExtraFields":"","itemDateModified":"","itemHits":"","itemCategory":"","itemTags":"","itemAttachments":"","itemAttachmentsCounter":"","itemVideo":"","itemVideoWidth":"","itemVideoHeight":"","itemAudioWidth":"","itemAudioHeight":"","itemVideoAutoPlay":"","itemVideoCaption":"","itemVideoCredits":"","itemImageGallery":"","itemNavigation":"","itemComments":"","itemTwitterButton":"","itemFacebookButton":"","itemGooglePlusOneButton":"","itemAuthorBlock":"","itemAuthorImage":"","itemAuthorDescription":"","itemAuthorURL":"","itemAuthorEmail":"","itemAuthorLatest":"","itemAuthorLatestLimit":"","itemRelated":"","itemRelatedLimit":"","itemRelatedTitle":"","itemRelatedCategory":"","itemRelatedImageSize":"","itemRelatedIntrotext":"","itemRelatedFulltext":"","itemRelatedAuthor":"","itemRelatedMedia":"","itemRelatedImageGallery":"","itemK2Plugins":""}
[metadesc] =>
[metadata] => robots=
author=
[metakey] =>
[plugins] =>
[language] => *
[categoryname] => News-test
[categoryid] => 4
[categoryalias] => news-test
[categoryparams] => {"inheritFrom":"0","theme":"","num_leading_items":"2","num_leading_columns":"1","leadingImgSize":"Large","num_primary_items":"4","num_primary_columns":"2","primaryImgSize":"Medium","num_secondary_items":"4","num_secondary_columns":"1","secondaryImgSize":"Small","num_links":"4","num_links_columns":"1","linksImgSize":"XSmall","catCatalogMode":"0","catFeaturedItems":"1","catOrdering":"","catPagination":"2","catPaginationResults":"1","catTitle":"1","catTitleItemCounter":"1","catDescription":"1","catImage":"1","catFeedLink":"1","catFeedIcon":"1","subCategories":"1","subCatColumns":"2","subCatOrdering":"","subCatTitle":"1","subCatTitleItemCounter":"1","subCatDescription":"1","subCatImage":"1","itemImageXS":"","itemImageS":"","itemImageM":"","itemImageL":"","itemImageXL":"","catItemTitle":"1","catItemTitleLinked":"1","catItemFeaturedNotice":"0","catItemAuthor":"1","catItemDateCreated":"1","catItemRating":"0","catItemImage":"1","catItemIntroText":"1","catItemIntroTextWordLimit":"","catItemExtraFields":"0","catItemHits":"0","catItemCategory":"1","catItemTags":"1","catItemAttachments":"0","catItemAttachmentsCounter":"0","catItemVideo":"0","catItemVideoWidth":"","catItemVideoHeight":"","catItemAudioWidth":"","catItemAudioHeight":"","catItemVideoAutoPlay":"0","catItemImageGallery":"0","catItemDateModified":"0","catItemReadMore":"1","catItemCommentsAnchor":"1","catItemK2Plugins":"1","itemDateCreated":"1","itemTitle":"1","itemFeaturedNotice":"1","itemAuthor":"1","itemFontResizer":"1","itemPrintButton":"1","itemEmailButton":"1","itemSocialButton":"1","itemVideoAnchor":"1","itemImageGalleryAnchor":"1","itemCommentsAnchor":"1","itemRating":"1","itemImage":"1","itemImgSize":"Large","itemImageMainCaption":"1","itemImageMainCredits":"1","itemIntroText":"1","itemFullText":"1","itemExtraFields":"1","itemDateModified":"1","itemHits":"1","itemCategory":"1","itemTags":"1","itemAttachments":"1","itemAttachmentsCounter":"1","itemVideo":"1","itemVideoWidth":"","itemVideoHeight":"","itemAudioWidth":"","itemAudioHeight":"","itemVideoAutoPlay":"0","itemVideoCaption":"1","itemVideoCredits":"1","itemImageGallery":"1","itemNavigation":"1","itemComments":"1","itemTwitterButton":"1","itemFacebookButton":"1","itemGooglePlusOneButton":"1","itemAuthorBlock":"1","itemAuthorImage":"1","itemAuthorDescription":"1","itemAuthorURL":"1","itemAuthorEmail":"0","itemAuthorLatest":"1","itemAuthorLatestLimit":"5","itemRelated":"1","itemRelatedLimit":"5","itemRelatedTitle":"1","itemRelatedCategory":"0","itemRelatedImageSize":"0","itemRelatedIntrotext":"0","itemRelatedFulltext":"0","itemRelatedAuthor":"0","itemRelatedMedia":"0","itemRelatedImageGallery":"0","itemK2Plugins":"1","catMetaDesc":"","catMetaKey":"","catMetaRobots":"","catMetaAuthor":""}
)
What am I missing here?
Any help will be appreciated.
Edit: I'm using Joomla v2.5.18 and K2 v2.6.8
This is how K2 Content module adds the image to the item Object (taken from mod_k2_content/helper.php):
//Images
if ($params->get('itemImage'))
{
$date = JFactory::getDate($item->modified);
$timestamp = '?t='.$date->toUnix();
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XS.jpg'))
{
$item->imageXSmall = JURI::base(true).'/media/k2/items/cache/'.md5("Image".$item->id).'_XS.jpg';
if ($componentParams->get('imageTimestamp'))
{
$item->imageXSmall .= $timestamp;
}
}
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_S.jpg'))
{
$item->imageSmall = JURI::base(true).'/media/k2/items/cache/'.md5("Image".$item->id).'_S.jpg';
if ($componentParams->get('imageTimestamp'))
{
$item->imageSmall .= $timestamp;
}
}
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_M.jpg'))
{
$item->imageMedium = JURI::base(true).'/media/k2/items/cache/'.md5("Image".$item->id).'_M.jpg';
if ($componentParams->get('imageTimestamp'))
{
$item->imageMedium .= $timestamp;
}
}
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_L.jpg'))
{
$item->imageLarge = JURI::base(true).'/media/k2/items/cache/'.md5("Image".$item->id).'_L.jpg';
if ($componentParams->get('imageTimestamp'))
{
$item->imageLarge .= $timestamp;
}
}
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XL.jpg'))
{
$item->imageXLarge = JURI::base(true).'/media/k2/items/cache/'.md5("Image".$item->id).'_XL.jpg';
if ($componentParams->get('imageTimestamp'))
{
$item->imageXLarge .= $timestamp;
}
}
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_Generic.jpg'))
{
$item->imageGeneric = JURI::base(true).'/media/k2/items/cache/'.md5("Image".$item->id).'_Generic.jpg';
if ($componentParams->get('imageTimestamp'))
{
$item->imageGeneric .= $timestamp;
}
}
$image = 'image'.$params->get('itemImgSize', 'Small');
if (isset($item->$image))
$item->image = $item->$image;
}
You should have everything you need, otherwise take a look at the K2 Content module.
You didn't mention which Joomla and K2 versions you are using.
For Joomla > 1.6 You should parse the "params" property like this:
$params = new JRegistry($item->params);
And get the image as follows
J 1.6 <=> J 2.5.14
$params->getValue('itemImage')
J >= 2.5.14
$params->get('itemImage')
Reference: http://api.joomla.org/cms-3/classes/JRegistry.html
Related
laravel how to add price product variations in laravel cart session
this is taking more than i anticipated, On my shopping cart app i'm able to add product to app cart session with no problem, But now i need to add product variations like (color, size, ... etc) for every product added to the cart, These variation can change to product price according to users selection on product details page. The code that i have currently is working for me except that i can't add a list of variation for a single product i can only create one variation then the code is replacing it with new variation value. This is my cart object when running {{print_r($cart)}} App\Cart Object ( [items] => Array ( [27] => Array ( [id] => 27 [name] => product with variation and colors [slug] => iphone-pro13 [price] => 100 [prefix] => QAR [qty] => 1 [poster] => /image/md/9964677a-c957-4510-9eb4-f41578c069b3 [subtotal] => 730 [quotable] => 0 [variations] => Array // these are the list of product variations ( [16] => Array ( [id] => 16 [var_name] => This is the variation [var_price] => 365.00 [var_qty] => 1 [var_subtotal] => 365 [color_code] => #e6bf00 ) ) ) [12] => Array ( [id] => 12 [name] => Dolore quis sunt reiciendis. [slug] => iste-autem-beatae-eaque-natus-distinctio [price] => 96.08 [prefix] => QAR [qty] => 1 [poster] => /media/default/product-placeholder.jpg [subtotal] => 350.692 [quotable] => 0 [variations] => Array // these are the list of product variations ( [0] => Array ( [var_name] => This is the variation 2 [var_price] => 335.00 [var_qty] => 1 [var_subtotal] => 365 [color_code] => #e6bf00 ) ) ) ) the is my cart.php class <?php namespace App; use Illuminate\Database\Eloquent\Model; class Cart extends Model { public $items = null; public $itemsCount = 0; public $grandTotal = 0; public $variations = null; public function __Construct($oldCart = null) { if($oldCart) { $this->items = $oldCart->items; $this->itemsCount = $oldCart->itemsCount; $this->grandTotal = $oldCart->grandTotal; $this->variations = $oldCart->variations; } } public function add($product) { if (isset($this->items)) { if( array_key_exists($product->id, $this->items) ) { $qty = $this->items[$product->id]['qty'] += $product->qty; $subtotal = $qty * $product->price; }else{ $qty = $product->qty; $subtotal = $product->subtotal; } }else{ $qty = $product->qty; $subtotal = $product->subtotal; } $item = [ 'id' => $product->id, 'name' => $product->name, 'slug' => $product->slug, 'price' => $product->price, 'prefix' => $product->prefix, 'qty' => $qty, 'poster' => $product->poster, 'subtotal' => $subtotal, 'quotable' => $product->quotable, ]; $variations = [ 'id' => $product->variation_id, 'var_name' => $product->variation, 'var_price' => $product->variation_price, 'var_qty' => $qty, 'var_subtotal' => $qty * $product->variation_price, 'color_code' => $product->color, ]; $this->items[$product->id] = $item; // <-- this adds new product $this->items[$product->id]['variations'][$product->variation_id] = $variations; // <-- this adds new product variation $this->itemsCount +=1; $this->grandTotal += $product->price * $product->qty; } } Not sure where my code went wrong but i need to be able to add list of product variations instead of replacing current ones. any ideas?
Laravel 1 row missing while inserting and
$purchase_line_datas = PurchaseLine::where('transaction_id', $transaction->id)->get(); $i = 0; $input = []; foreach ($purchase_line_datas as $key => $purchase_line_data) { if (!$enable_stock_transfer) { $qty_available = $this->productUtil->num_uf($purchases[$i]['quantity']); } else { $qty_available = 0; } $item = array( "business_id" => $business_id, "transaction_id" => $purchase_line_data->transaction_id, "purchase_line_id" => $purchase_line_data->id, "variation_id" => $purchase_line_data->variation_id, "contact_id" => $transaction_data['contact_id'], "product_id" => $purchase_line_data->product_id, "ref_no" => $ref_no, "new_barcode" => $purchase_line_data->barcode, "default_sell_price" => $this->productUtil->num_uf($purchases[$i]['default_sell_price']), "purchase_qty" => $this->productUtil->num_uf($purchases[$i]['quantity']), "qty_available" => $this->productUtil->num_uf($qty_available), "created_at" => Carbon::now() ); array_push($input, $item); $i++; } ProductPurchaseSl::insert($input); in this code I am inserting an array but after inserting.. it's showing that one row is missing.And it's happening very often.I couldn't be able to solve this problem.
Linking arrays according to common values
I have some array like 0: [id: '1',department: 'xyz',date: '10-10-2019',time: '12:50'] 1: [id: '1',department: 'xyz',date: '11-10-2019',time: '10:30'] 2: [id: '2',department: 'abc',date: '09-09-2019',time: '09:50'] 3: [id: '2',department: 'abc',date: '07-07-2019',time: '03:20'] I want them to be merged according to the id and department so the 0 and 1 array will be merged together and the output should be something like 0:[id: '1',department: 'xyz',[[date: '10-10-2019',time: '12:50'],[date: '11-10-2019',time: '10:30']]] and the 2 and 3 array will be merged together and the output should be something like 1:[id: '2',department: 'abc',[[date: '09-09-2019',time: '09:50'],[date: '07-07-2019',time: '03:20']]] how can I do it?
Try this.. $input = [ 0 =>['id' => '1','department' => 'xyz','date' => '10-10-2019','time' => '12:50'], 1 => ['id' => '1','department' => 'xyz','date' => '11-10-2019','time' => '10:30'], 2 => ['id' => '2','department' => 'abc','date' => '09-09-2019','time' => '09:50'], 3 =>['id' => '2','department' => 'abc','date' => '07-07-2019','time' => '03:20']]; $output = []; $id_array = []; foreach ($input as $values) { $id_array [] = $values['id']; } $unique_id_array = array_unique($id_array); foreach($input as $key => $in) { if(array_key_exists($key,$unique_id_array)) { $output[] = [ 'department' => $in['department'], 'id' => $in['id'] ]; } } foreach($input as $in) { foreach($output as $key => $out) { if($out['id'] == $in['id'] && $out['department'] == $in['department']) { $output[$key]['date_time'][] = ['date' =>$in['date'],'time' => $in['time']]; } } } print_r($output);die(); The output is going to be Array ( [0] => Array ( [department] => xyz [id] => 1 [date_time] => Array ( [0] => Array ( [date] => 10-10-2019 [time] => 12:50 ) [1] => Array ( [date] => 11-10-2019 [time] => 10:30 ) ) ) [1] => Array ( [department] => abc [id] => 2 [date_time] => Array ( [0] => Array ( [date] => 09-09-2019 [time] => 09:50 ) [1] => Array ( [date] => 07-07-2019 [time] => 03:20 ) ) ) )
Hello i think this will works fine,and it's easy and best way to achieve your output. i tried many codes in my system with data given by you,just try this i hope this will work for you as well. <?php $inputArr = [0 =>['id' => '1','department' => 'xyz','date' => '10-10-2019','time' => '12:50'],1 => ['id' => '1','department' => 'xyz','date' => '11-10-2019','time' => '10:30'],2 => ['id' => '2','department' => 'abc','date' => '09-09-2019','time' => '09:50'],3 =>['id' => '2','department' => 'abc','date' => '07-07-2019','time' => '03:20']]; print_r($inputArr); $second_copy = $inputArr; foreach ($inputArr as $key => $single) { $goalArr[$single['id']] = getRow($single['id'],$single['department'],$second_copy); } function getRow($id,$department,$second_copy) { $returnArr['id'] = $id; $returnArr['department'] = $department; foreach ($second_copy as $key => $single) { if($id == $single['id'] && $department == $single['department']) { $returnArr['date'][] = $single['date']; $returnArr['time'][] = $single['time']; } } return $returnArr; } echo "<br>Output is: <br>"; print_r($goalArr); ?>
Edit Form in Laravel: Creates New Entry instead of Updating Old Data
I tried to create edit method on form data submission, but instead of updating the old entry, it creates a new entry in the database. My source files are: web.php Route::get('/input_gedung_bangunan/{id_bangunan}', 'input_gedung_bangunan#tampiledit'); Route::post('/data_gedung_bangunan/hitung_data', 'input_gedung_bangunan#store'); Controller: public function store(Request $request){ //DB::enableQueryLog(); //$id_bangunan = $id; $validation = \App\Tbl_uraian_datas::where('id_bangunan', '=', $request->get('id_bangunan'))->first(); if(is_null($validation)){ $tbl_uraian_datas = new \App\Tbl_uraian_datas; $tbl_uraian_datas->id_bangunan = $request->get('id_bangunan'); $tbl_uraian_datas->id_kanwil = Input::get('IDKanwil'); $tbl_uraian_datas->id_kota_kab = Input::get('IDKotaKab'); $tbl_uraian_datas->nomor_baris = Input::get('NomorBaris'); $tbl_uraian_datas->nama_bangunan = Input::get('NamaBangunan'); $tbl_uraian_datas->alamat_bangunan = Input::get('AlamatBangunan'); $tbl_uraian_datas->nama_kota_kab = Input::get('Kota/Kabupaten'); $tbl_uraian_datas->kode_barang = Input::get('KodeBarang'); $tbl_uraian_datas->nup_barang = Input::get('NUPBarang'); $tbl_uraian_datas->luas_lantai = Input::get('LuasLantai'); $tbl_uraian_datas->jumlah_lantai = Input::get('JumlahLantai'); $tbl_uraian_datas->tahun_penilaian = Input::get('TahunPenilaian'); $tbl_uraian_datas->tahun_dibangun = Input::get('TahunDibangun'); $tbl_uraian_datas->tahun_direnovasi = Input::get('TahunDirenovasi'); $tbl_uraian_datas->id_jenis_bangunan = Input::get('IDJenisBangunan'); $tbl_uraian_datas->jenis_bangunan = Input::get('JenisBangunan'); $tbl_uraian_datas->id_kategori = Input::get('IDKategoriBangunan'); $tbl_uraian_datas->kategori_bangunan = Input::get('KategoriBangunan'); $tbl_uraian_datas->id_kondisi = Input::get('IDKondisiBangunan'); $tbl_uraian_datas->kondisi_bangunan = Input::get('KondisiBangunan'); $tbl_uraian_datas->luas_carport = Input::get('LuasCarport'); $tbl_uraian_datas->panjang_pagar_material1 = Input::get('PanjangPagar1'); $tbl_uraian_datas->panjang_pagar_material2 = Input::get('PanjangPagar2'); $tbl_uraian_datas->panjang_pagar_material3 = Input::get('PanjangPagar3'); $tbl_uraian_datas->harga_per_m2 = Input::get('Hargaperm2'); $tbl_uraian_datas->alasan_fisik = Input::get('Alasan1'); $tbl_uraian_datas->penyusutan = Input::get('Penyusutan'); $tbl_uraian_datas->alasan_penyusutan = Input::get('Alasan2'); $tbl_uraian_datas->save(); }else{ //Edit Data Gedung/Bangunan $tbl_uraian_datas = \App\Tbl_uraian_datas::update(['id_kanwil' => Input::get('IDKanwil'), 'id_kota_kab' => Input::get('IDKotaKab'), 'nomor_baris' => Input::get('NomorBaris'),'nama_bangunan' => Input::get('nama_bangunan'),'alamat_bangunan' => Input::get('AlamatBangunan'),'nama_kota_kab' => Input::get('Kota/Kabupaten'),'kode_barang' => Input::get('KodeBarang'),'nup_barang' => Input::get('NUPBarang'),'luas_lantai' => Input::get('LuasLantai'),'jumlah_lantai' => Input::get('JumlahLantai'),'tahun_penilaian' => Input::get('TahunPenilaian'),'tahun_dibangun' => Input::get('TahunDibangun'),'tahun_direnovasi' => Input::get('TahunDirenovasi'),'id_jenis_bangunan' => Input::get('IDJenisBangunan'),'jenis_bangunan' => Input::get('JenisBangunan'),'id_kategori' => Input::get('IDKategoriBangunan'),'kategori_bangunan' => Input::get('KategoriBangunan'),'id_kondisi' => Input::get('IDKondisiBangunan'),'kondisi_bangunan' => Input::get('KondisiBangunan'),'luas_carport' => Input::get('LuasCarport'),'panjang_pagar_material1' => Input::get('PanjangPagar1'),'panjang_pagar_material2' => Input::get('PanjangPagar2'),'panjang_pagar_material3' => Input::get('PanjangPagar3'),'harga_per_m2' => Input::get('Hargaperm2'),'alasan_fisik' => Input::get('Alasan1'),'penyusutan' => Input::get('Penyusutan'),'alasan_penyusutan' => Input::get('Alasan2')]); //$tbl_hasil_perhitungans = \App\Tbl_hasil_perhitungans::where('id_bangunan', '=',$request->get('id_bangunan'))->update(['umur_efektif_bangunan' => Input::get('nUmurEfektifBangunan'), 'pembulatan' => Input::get('nPembulatan')]); $request->session()->flash('alert-success', 'Data Gedung Bangunan was successfully added!'); return back(); } } It looks like the controller keeps making the new id for the editted data and I don't know what I did wrong in my controller.
Instead of the following lines in your code: $validation = \App\Tbl_uraian_datas::where('id_bangunan', '=', $request->get('id_bangunan'))->first(); if(is_null($validation)){ Try this: $validation = \App\Tbl_uraian_datas::where('id_bangunan', $request->input('id_bangunan'))->first(); if(empty($validation)){ AND instead of $tbl_uraian_datas = \App\Tbl_uraian_datas::update(['id_kanwil' => Input::get('IDKanwil'), 'id_kota_kab' => Input::get('IDKotaKab'), 'nomor_baris' => Input::get('NomorBaris'),'nama_bangunan' => Input::get('nama_bangunan'),'alamat_bangunan' => Input::get('AlamatBangunan'),'nama_kota_kab' => Input::get('Kota/Kabupaten'),'kode_barang' => Input::get('KodeBarang'),'nup_barang' => Input::get('NUPBarang'),'luas_lantai' => Input::get('LuasLantai'),'jumlah_lantai' => Input::get('JumlahLantai'),'tahun_penilaian' => Input::get('TahunPenilaian'),'tahun_dibangun' => Input::get('TahunDibangun'),'tahun_direnovasi' => Input::get('TahunDirenovasi'),'id_jenis_bangunan' => Input::get('IDJenisBangunan'),'jenis_bangunan' => Input::get('JenisBangunan'),'id_kategori' => Input::get('IDKategoriBangunan'),'kategori_bangunan' => Input::get('KategoriBangunan'),'id_kondisi' => Input::get('IDKondisiBangunan'),'kondisi_bangunan' => Input::get('KondisiBangunan'),'luas_carport' => Input::get('LuasCarport'),'panjang_pagar_material1' => Input::get('PanjangPagar1'),'panjang_pagar_material2' => Input::get('PanjangPagar2'),'panjang_pagar_material3' => Input::get('PanjangPagar3'),'harga_per_m2' => Input::get('Hargaperm2'),'alasan_fisik' => Input::get('Alasan1'),'penyusutan' => Input::get('Penyusutan'),'alasan_penyusutan' => Input::get('Alasan2')]); Try: $tbl_uraian_datas = \App\Tbl_uraian_datas::where('id_bangunan',$request->input('id_bangunan'))->update(['id_kanwil' => Input::get('IDKanwil'), 'id_kota_kab' => Input::get('IDKotaKab'), 'nomor_baris' => Input::get('NomorBaris'),'nama_bangunan' => Input::get('nama_bangunan'),'alamat_bangunan' => Input::get('AlamatBangunan'),'nama_kota_kab' => Input::get('Kota/Kabupaten'),'kode_barang' => Input::get('KodeBarang'),'nup_barang' => Input::get('NUPBarang'),'luas_lantai' => Input::get('LuasLantai'),'jumlah_lantai' => Input::get('JumlahLantai'),'tahun_penilaian' => Input::get('TahunPenilaian'),'tahun_dibangun' => Input::get('TahunDibangun'),'tahun_direnovasi' => Input::get('TahunDirenovasi'),'id_jenis_bangunan' => Input::get('IDJenisBangunan'),'jenis_bangunan' => Input::get('JenisBangunan'),'id_kategori' => Input::get('IDKategoriBangunan'),'kategori_bangunan' => Input::get('KategoriBangunan'),'id_kondisi' => Input::get('IDKondisiBangunan'),'kondisi_bangunan' => Input::get('KondisiBangunan'),'luas_carport' => Input::get('LuasCarport'),'panjang_pagar_material1' => Input::get('PanjangPagar1'),'panjang_pagar_material2' => Input::get('PanjangPagar2'),'panjang_pagar_material3' => Input::get('PanjangPagar3'),'harga_per_m2' => Input::get('Hargaperm2'),'alasan_fisik' => Input::get('Alasan1'),'penyusutan' => Input::get('Penyusutan'),'alasan_penyusutan' => Input::get('Alasan2')]); You need to tell which row to actually update by giving a where clause
Coinpayment Laravel integration. Division by zero Exception
I am trying to integrate coinpayment. By using this - https://github.com/hexters/CoinPayment But I got error says: exception: "ErrorException" file: "C:\xampp\htdocs\coinpayment\vendor\hexters\coinpayment\src\Http\Controllers\CoinPaymentController.php" line: 45 message: "Division by zero"
Please Refer to author new commits in the git repository as he updated the package https://github.com/hexters/CoinPayment/commit/cf7de99e18948fe385e75dfa8ded0fb378c33ad4 In case the link is not working then go to your app route and then to vendor folder and follow path vendor/hexters/coinpayment/src/Http/Controllers and update CoinPaymentController.php file's public function ajax_rates() function with the below given code public function ajax_rates(Request $req, $usd){ $coins = []; $aliases = []; $rates = CoinPayment::api_call('rates', [ 'accepted' => 1 ])['result']; $rateBtc = $rates['BTC']['rate_btc']; $rateUsd = $rates[config('coinpayment.default_currency')]['rate_btc']; $rateAmount = $rateUsd * $usd; $fiat = []; $coins_accept = []; foreach($rates as $i => $coin){ if((FLOAT) $rates[$i]['rate_btc'] > 0) { if((INT) $coin['is_fiat'] === 0){ $rate = ($rateAmount / $rates[$i]['rate_btc']); $coins[] = [ 'name' => $coin['name'], 'rate' => number_format($rate,8,'.',''), 'iso' => $i, 'icon' => 'https://www.coinpayments.net/images/coins/' . $i . '.png', 'selected' => $i == 'BTC' ? true : false, 'accepted' => $coin['accepted'] ]; $aliases[$i] = $coin['name']; } if((INT) $coin['is_fiat'] === 0 && $coin['accepted'] == 1){ $rate = ($rateAmount / $rates[$i]['rate_btc']); $coins_accept[] = [ 'name' => $coin['name'], 'rate' => number_format($rate,8,'.',''), 'iso' => $i, 'icon' => 'https://www.coinpayments.net/images/coins/' . $i . '.png', 'selected' => $i == 'BTC' ? true : false, 'accepted' => $coin['accepted'] ]; } if((INT) $coin['is_fiat'] === 1){ $fiat[$i] = $coin; } } } return response()->json([ 'coins' => $coins, 'coins_accept' => $coins_accept, 'aliases' => $aliases, 'fiats' =>$fiat ]); }