Support the ongoing development of Laravel.io →
Eloquent Views Blade
Last updated 2 years ago.
0

No one help me?

Last updated 2 years ago.
0

Have you tried using javascript?

Last updated 2 years ago.
0

extjac said:

Have you tried using javascript?

hi Extjac Thank for you comment

but i just want to push my data itself, it mean category table (it has parent) to combobox for display, i dont think i need to use javascript for this?

Last updated 2 years ago.
0

kencytbb said:

My category name is testzzz and parent category of testzzz is events but it nonfather category is selected

               <select name="catfather">
               @foreach($catefather as $cf)
               @if($cate->parents->idcategory != $cf->idcategory)                                               
               <option value="{{$cf->idcategory}}}" selected>{{{$cf->cat_name}}}</option>
               @else
                <option  selected disabled hidden value=''></option>"      
                <option value="{{$cf->idcategory}}}">{{{$cf->cat_name}}}</option>
                @endif
               @endforeach  
               </select>

Excuse me, but your if statement seems wrong to me.
If the parent id ($cate->parents) equals the id of the category in the foreach ($cf) then it sould be selected. Otherwise not. You are doing the opposite. Replace != with ==.
You don't need the option which is disabled inside the else, you need it right before the foreach.
I strongly racommend you to change the name of the select from "catfather" to "cat_father". In your edit view, laravel will automaticlly recognize the temporary value and set it as selected.

Last updated 2 years ago.
0

Hello,

I did same thing for one of my project, and Its better to utilize the power of relationships and scopes in eloquent. I had a nice structured model in my case, but here is modified version from that model for you.

http://laravel.io/bin/6Ln34

Hope that helps you!

Last updated 2 years ago.
0

Firtzberg said:

kencytbb said:

My category name is testzzz and parent category of testzzz is events but it nonfather category is selected

               <select name="catfather">
               @foreach($catefather as $cf)
               @if($cate->parents->idcategory != $cf->idcategory)                                               
               <option value="{{$cf->idcategory}}}" selected>{{{$cf->cat_name}}}</option>
               @else
                <option  selected disabled hidden value=''></option>"      
                <option value="{{$cf->idcategory}}}">{{{$cf->cat_name}}}</option>
                @endif
               @endforeach  
               </select>

Excuse me, but your if statement seems wrong to me.
If the parent id ($cate->parents) equals the id of the category in the foreach ($cf) then it sould be selected. Otherwise not. You are doing the opposite. Replace != with ==.
You don't need the option which is disabled inside the else, you need it right before the foreach.
I strongly racommend you to change the name of the select from "catfather" to "cat_father". In your edit view, laravel will automaticlly recognize the temporary value and set it as selected.>dakshhmehta said:

Hello,

I did same thing for one of my project, and Its better to utilize the power of relationships and scopes in eloquent. I had a nice structured model in my case, but here is modified version from that model for you.

http://laravel.io/bin/6Ln34

Hope that helps you!

thank you very much i did it, it work well :P

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

kencytbb kencytbb Joined 29 Oct 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.