How can I get the image url stored in my database and render it on the page in laravel 4?
Very vague question, so will be the answer. Please clarify if it's not what you need.
Assumptions: You have an Item model that is stored in a DB. In the relevant controller method you add the code below which will find the item with id 1 and will display the field named "url".
$item = Item::whereId(1)->first();
echo $item->url;
Related
I fetched product data by using collection factory from (Magento\Catalog\Model\ResourceModel\Product\CollectionFactory). Then passed those data in template by block. Data has been fetched successfully but when i try to edit by
Edit
getUrl doesn't generate a valid link.
i want a Url link this
http://localhost/magento2/admin/catalog/product/edit/id/1/key/bfe08a05118e8a063718ecf5804669494dca697b13782ee7a074d9f42344d28a/
but i am getting like this
http://localhost/magento2/admin/catalog/product/edit/key/bfe08a05118e8a063718ecf5804669494dca697b13782ee7a074d9f42344d28a/
As you can see my link doesn't have any ID in between edit and key.
I think i am missing something. Please help
I'm actually working in a little forum project, everything is fine till I was stuck in a problem.
I want to display the user Image in front of every post he creates.
I have a table called discussion and another called users and each one of them contains the "user_id" column, but I couldn't figure out how to link them.
firstly you need to know about relation ship between the database table. then you need to learn about eloquent relationship on laravel docs.
https://laravel.com/docs/5.6/eloquent-relationships
I wanted to implement multi level data table structure with Laravel Backpack. Please see the images for more information
structure - https://ibb.co/i9Qfud
initial view - https://ibb.co/h8SFSy
trip expanded - https://ibb.co/cm027y
city expanded - https://ibb.co/ej3N7y
day expanded - https://ibb.co/iGffud
Is this possible with Laravel backpack ? Any references where i can find a solution?
Thanks in advance :)
There's a Backpack functionality called Details Row that will help you achieve the first [+] button, but I'm afraid that's about it - the next ones are up to you.
You will have to:
in your TripCrudController::setup():
$this->crud->enableDetailsRow();
$this->crud->allowAccess('details_row');
$this->crud->setDetailsRowView('details_row.expanded_trip_details_row');
create the blade file that outputs the table with cities, days and attractions (let's say resources/views/vendor/backpack/crud/details_row/expanded_trip_details_row.blade.php); shouldn't be very difficult, you have the current trip as $entry inside this file and you can drill down using Eloquent relationships into $cities = $entry->cities, then $days=$city->days etc;
include some javascript so that subsequent [+] signs work, inside your public/vendor/backpack/crud/js/list.js; alternatively, you could do this with inline javascript inside the same blade file, might be cleaner that way; but remember that this blade content is put inside the details row with AJAX, so new DOM elements and events need to be registered;
Hope it helps.
Tabacitu has provided the right answer but i've observed in my case that the details_row template should be called this way :
$this->crud->setDetailsRowView('backpack::crud.details_row.expanded_trip_details_row');
first of all, sorry for my english, but I'll try to explain myself best I can.
My question is little tricky, because I made some important changes in the core code of VirtueMart.
For some reasons, I added an attribute to the Custom Fields, like Price, called Availability.
TIP: The admin site is in Spanish. Disponibilidad = Availability
So, now, when I try to change any value of any created Custom Field, I can't save it. I mean, I can change the value, but when I apply them, It doesn't be saved.
The only field that I can change, is the field I created, the Availability (ironically).
So, my principal question is, how does VirtueMart to pick up the data from the table and sends them to the database?
I work with
Joomla v.2.5.11
VirtueMart 2
Thanks
The workflow is like follows,
When you save the products details on the backend , It calls a function store() on the product.php model. under administrator/components/com_virtuemart/models/. Inside this function an area like follows.
if(!class_exists('VirtueMartModelCustom')) require(JPATH_VM_ADMINISTRATOR.DS.'models'.DS.'custom.php');
VirtueMartModelCustom::saveModelCustomfields('product',$data,$product_data->virtuemart_product_id);
It loading the custom model file from the same path and do the task inside saveModelCustomfields()
Hope it helps..
I am trying to build a form for a Happening. The Happening references a Places table by place_id.
e.g. happening "OktoberFest" has a place_id 123 which corresponds in table Places to München
These are the relationships declared in the models:
For model Place:
public function happenings()
{
return $this->hasMany('Happening');
}
For model Happening:
public function place()
{
return $this->belongsTo('Place');
}
model Happening has a place_id field linking it to Place.
I am also using {{Form::model($happening, array('route' => array('happenings.update', $happening->id)...}} as form opening
Problem 1: how to create a {{Form::text('......')}} that will be properly prefilled with München when editing the happening Oktoberfest ?
Problem 2: I was trying to get that field to work as an ajax autosuggest (i.e. starting to pull suggestions from the Places table as soon as 3 characters have been entered). I have checked a few implementations but they don't seem to mix correctly with Problem 1
To try and solve Problem 1, I have tried the solution here
Laravel 4 Form builder Custom Fields Macro
but I was unable to make it work.
Long question, it's my very first on stack overflow, please be patient :)
If a Happening is linked to Place via the column 'place_id' you have to supply an id to save in your model/table.
There are a couple of ways that I can think of:
make a list of availble Places in a radio of select, the name will be 'place_id', the value the id of the Place en something like title for the value.
instead of displaying radio's or a select a textfield with autocomplete is a great solution if you got a lot of places. I won't go into detail how to implement it but the general idea is to autocomplete the typed in placename and on selection of that place to put the id of that place in a hidden field named 'placed_id'
After saving the form save your model with the posted place_id
(and check that id if it's valid and existing, never trust user input )