saadat_2003

Experience

950

0 Best Reply Awards

  • Member Since 6 Months Ago
  • 3 Lessons Completed
  • 0 Favorites

12th April, 2018

saadat_2003 left a reply on Checkbox And Radio Button Not Saving Selected Option Against Multiple Items In Survey App In Laravel 5.6 • 1 month ago

thanks.am trying.need any suggestions regarding above code @spekkionu

saadat_2003 left a reply on Checkbox And Radio Button Not Saving Selected Option Against Multiple Items In Survey App In Laravel 5.6 • 1 month ago

yes I know.The problem is that when I add more than one questions with checkbox or radio button in my survey,When i select checkbox or radio button for first question it is selected and saves "on" keyword in db not the actual value.whenever i try to select other question's checkbox or radio button they are not active.When I click on them,again It start selecting first or some times second question with checkbox or radio button option.Not that one which I want to select.And again It saves "on" keyword in database again first question's answer @Cinek

saadat_2003 started a new conversation Checkbox And Radio Button Not Saving Selected Option Against Multiple Items In Survey App In Laravel 5.6 • 1 month ago

when I start adding answers in survey It is not saving answers on radio buttons and check boxes and only one question with checkbox or radio button on top of form is selected.

It saves only one question at a time or some times null or "on" keyword against checkbox or radio answers.Only first question with checkbox or radio button options can be selected.

When I try to selected other question's answer ,again only first question options are selected and only they are saving in db .kindly check the code and files and help me.

Only "on" keyword string is stored when I try to save checkbox or radio button options answer.If their is only one question with text the survey runs but in multiple it does not working with other questions.

Survey view

<div class="card">
      <div class="card-content">
      <span class="card-title"> Start taking Survey</span>
      <p>
      <span class="flow-text">{{$survey->title}}</span> <br/>
      </p>
      <p>  
      {{$survey->description}}
      <br>Created by: <a href="">{{$survey->user->name}}</a>
      </p>
      <div class="divider" style="margin:20px 0px;"></div>
      {!! Form::open(array('action'=>array('[email protected]',$survey->id)))!!}
      @forelse($survey->questions as $key=>$question)
      <p class="flow-text">Question {{$key+1}} - {{$question->title}}</p>
      @if($question->question_type==='text')
      <div class="input-field col s12">
                    <input id="answer" type="text" name="{{$question->id}}[answer]">
                    <label for="answer">Answer </label>
                  </div>
                  @elseif($question->question_type==='textarea')
                  <div class="input-field col s12">
                  <textarea id="textarea1" class="materialize-textarea" name="{{ $question->id }}[answer]"></textarea>
                  <label for="textarea1">Textarea</label>
                </div>
                @elseif($question->question_type==='radio')
                @foreach($question->option_name as $key=>$value)

                      <p style="margin:0px; padding:0px;">
                      <input name="{{$question->id}}[answer]" type="radio" id="{{ $key }}" />
                      <label for="{{$key}}">{{$value}}</label>
                      </p>
                      @endforeach
                      @elseif($question->question_type==='checkbox')
                      @foreach($question->option_name as $key=>$value)
                      <p style="margin:0px; padding:0px;">
                      <input type="checkbox" id="something{{$key}}" name="{{$question->id}}[answer]"/>
                      <label for="something{{$key}}">{{$value}}</label>
                      </p>
                      @endforeach
                      @endif
                      <div class="divider" style="margin:10px 10px;"></div>
                      @empty
            <span class='flow-text center-align'>Nothing to show</span>
          @endforelse
          {{Form::submit('Submit Survey',array('class'=>'btn waves-effect waves-light'))}} 
          {!!Form::close()!!}
          </div>
  </div>

Answer controller

public function store(Request $request,Survey $survey){
        $arr=$request->except('_token');
        foreach($arr as $key=>$value){
            $newAnswer=new Answer();
            if(!is_array($value)){
                $newValue=$value['answer'];
            }
            else{
                $newValue=json_encode($value['answer']);
            }
            $newAnswer->answer=$newValue;
            $newAnswer->question_id=$key;
            $newAnswer->user_id=Auth::id();
            $newAnswer->survey_id=$survey->id;
            $newAnswer->save();
            $answerArray=$newAnswer;
            return redirect()->action('[email protected]_survey_answers',[$survey->id]);
        }

29th March, 2018

saadat_2003 started a new conversation Code Not Displaying Answers Fields For Questions In Survey App On Laravel 5.6 • 1 month ago

I am working on survey app and creating surveys successfully and also adding questions to it but my code for answers is not working as I have used if else and for loops to add answers here is my code:

Start taking Survey

{{$survey->title}}

{{$survey->description}} Created by: {{$survey->user->name}}

{!! Form::open(array('action'=>array('[email protected]',$survey->id)))!!} @forelse($survey->questions as $key=>$question)

Question {{$key+1}} - {{$question->title}}

@if($question->question_type==='text') Answer @elseif($question->question_type==='textarea') Textarea @elseif($question->question_type==='radio') @foreach($question->option_name as $key=>$value)
                  <p style="margin:0px; padding:0px;">
                  <input name="{{$question->id}}[answer]" type="radio" id="{{ $key }}" />
                  <label for="{{$key}}">{{$value}}</label>
                  </p>
                  @endforeach
                  @elseif($question->question_type==='checkbox')
                  @foreach($question->option_name as $key=>$value)
                  <p style="margin:0px; padding:0px;">
                  <input type="checkbox" id="something{{$key}}" name="{{$question->id}}[answer]"/>
                  <label for="something{{$key}}">{{$value}}</label>
                  </p>
                  @endforeach
                  @endif
                  <div class="divider" style="margin:10px 10px;"></div>
                  @empty
        <span class='flow-text center-align'>Nothing to show</span>
      @endforelse
      {{Form::submit('Submit Survey',array('class'=>'btn waves-effect waves-light'))}} 
      {!!Form::close()!!}
      </div>

24th November, 2017

saadat_2003 left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage • 5 months ago

The query is working correctly in mysql .I want to write it in my controller. @tisuchi @RamjithAp

SELECT cname FROM categories where cid IN(SELECT max(category) FROM items group by category order by category desc ) order by cid desc LIMIT 10

saadat_2003 left a reply on Search In Laravel 5.5 • 5 months ago

@mushood The query is working correctly in mysql .I want to write it in my controller.

SELECT cname FROM categories where cid IN(SELECT max(category) FROM items group by category order by category desc ) order by cid desc LIMIT 10

saadat_2003 left a reply on Search In Laravel 5.5 • 5 months ago

The query is working correctly in mysql .I want to write it in my controller.

SELECT cname FROM categories where cid IN(SELECT max(category) FROM items group by category order by category desc ) order by cid desc LIMIT 10

saadat_2003 left a reply on Display Sub Categories On Seperate Page When Clicked On Category Link In Home Page • 5 months ago

@RamjithAp Kindly help me ,How to write this mysql format query in laravel controller

SELECT cname FROM categories where cid IN(SELECT max(category) FROM items group by category order by category desc ) order by cid desc LIMIT 10

21st November, 2017

saadat_2003 left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage • 6 months ago

@foreach($category->subcategories as $subcategory)

{{ $subcategory->csname}}

@endforeach and then I have set protected $primaryKey = 'cid'; in category model then error resolved Also add this to your reply that I have accepted @RamjithAp

saadat_2003 left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage • 6 months ago

Its solved .Thanks a lot friend .you have helped a lot

saadat_2003 left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage • 6 months ago

I have set protected $primaryKey = 'cid'; in category model .Now that error is not showing but when i write this in controller return $subcategories; it gives correct [{"csid":35,"cid":17,"csname":"Civic","csStatus":null}] but on this gives error Undefined variable: subcategories (View: C:\xampp\htdocs\carzhub\resources\views\search-categories.blade.php) Again Thanks for your help @RamjithAp

saadat_2003 left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage • 6 months ago

thanks bro @RamjithAp , You have helped out very much ,I have also learned very much. I have created foreign key relationship. Now getting this error, but their is no id column SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: select * from categories where id = 17 limit 1)

saadat_2003 left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage • 6 months ago

thanks bro, You have helped out very much ,I have also learned very much. I have created foreign key relationship. Now getting this error, but their is no id column SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: select * from categories where id = 17 limit 1)

20th November, 2017

saadat_2003 left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage • 6 months ago

Bro Thanks for your help , I have pasted all the code here https://pastebin.com/8CdSyeDz kindly check it @RamjithAp

saadat_2003 left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage • 6 months ago

@RamjithAp kindly tell me about best tutorial in laravel 5.5 that would help me in completing this task .I just want to display subcategories on single detail page under the category which is clicked from index page .kindly help me as I am trying to do this since last week

saadat_2003 left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage • 6 months ago

subcategory is table name?

saadat_2003 left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage • 6 months ago

@RamjithAp any idea about this Property [subcategories] does not exist on this collection instance.

17th November, 2017

saadat_2003 left a reply on Display Sub Categories On Seperate Page When Clicked On Category Link In Home Page • 6 months ago

@RamjithAp I have commented all my code above , kindly review it and tell me if their is anything wrong

saadat_2003 left a reply on Display Sub Categories On Seperate Page When Clicked On Category Link In Home Page • 6 months ago

should I only change my route to the above anything else needed to change in all above code @satish9323

saadat_2003 left a reply on Display Sub Categories On Seperate Page When Clicked On Category Link In Home Page • 6 months ago

@satish9323 I have commented whole scenerio . when I passed $id argument it gives this error Missing argument 1 for App\Http\Controllers\SubCatController::index()

saadat_2003 left a reply on Display Sub Categories On Seperate Page When Clicked On Category Link In Home Page • 6 months ago

in categoies.blade.php

@foreach($categories as $category) {{$category['cname']}} @endforeach

in search-categories.blade.php @foreach($subcategories as $subcategory) {{ $subcategory->name}} @endforeach

in Category.php class Category extends Model { // public $table='categories'; protected $fillable=[

    'cid',
    'cname'
    
];
public function subcategories(){
    return $this->hasMany('App\SubCategory','cid');   
}

}

in SubCategory.php

class SubCategory extends Model { // public $table='categories_sub'; protected $fillable = ['cid', 'csname'];

        public function categories()
        {
            return $this->belongsTo('App\Categories','cid');
        }
    

}

in SubCatController

public function index($id) { //

    $category =  Category::find($id);
    $subcategories= Category::find($id)->subcategories;
    
    return view('search-categories')->withCategory($category)->withSubcategories($subcategories); 
}

in CategoriesController public function index() { // $categories = Category::all()->toArray(); return view('categories', compact('categories')); }

I just want when user click on category link herf in categories.blade.php , then It should go to search-categories.blade.php and display sub categories of that specific categories

in routes web.php

Route::get('/search-categories', function () { return view('search-categories'); }); Route::get('/categories', function () { return view('categories'); });

Route::resource('Categories','CategoriesController'); Route::resource('search-categories','SubCatController');

Route::get('/','[email protected]'); Route::get('/','[email protected]');

DB Tables Categories (cid,cname) Categories_sub(csid,cid,csname,) cid is category id but migration is not created and also not foreign key relationship

saadat_2003 left a reply on Display Sub Categories On Seperate Page When Clicked On Category Link In Home Page • 6 months ago

@satish9323 public function index() { //

    $category =  Category::find($id);
    $subcategories= Category::find($id)->subcategories;
    
    return view('search-categories')->withCategory($category)->withSubcategories($subcategories); 
}

saadat_2003 left a reply on Display Sub Categories On Seperate Page When Clicked On Category Link In Home Page • 6 months ago

@RamjithAp thanks for helping a lot.

I have done this all $category = Category::find($id); $subcategories= Category::find($id)->subcategories; Now getting error Undefined variable: id

saadat_2003 left a reply on Gettting Un Defined Variable Error • 6 months ago

Route::get('/categories', function () { return view('categories'); }); Route::resource('Categories','CategoriesController'); Route::get('/','[email protected]');

I have added these lines in web.php , but when click on any other button on home page it always show this error @saurabhd

saadat_2003 started a new conversation Gettting Un Defined Variable Error • 6 months ago

Undefined variable: categories (View: C:\xampp\htdocs\carzhub\resources\views\categories.blade.php)

saadat_2003 started a new conversation Display Sub Categories On Seperate Page When Clicked On Category Link In Home Page • 6 months ago

I have displayed categories link on homepage and getting id in $category[cname] I have category id in sub_category table.now I want to display all sub categories belong to that category

saadat_2003 left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage • 6 months ago

@RamjithAp thanks for ur help , I have table of categories_sub ,I have category id in sub category table .Now I want to display sub categories for a specific category link which is clicked

16th November, 2017

saadat_2003 left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage • 6 months ago

@tisuchi I have written this code in header.blade.php . what would be the href for me in this line href="/category/{{ $category->id }}"

saadat_2003 started a new conversation Display Sub Categories Under A Particular Category Clicked From Homepage • 6 months ago

any one help me as I have displayed categories(categories table) name on index using index function , $categories = Category::all()->toArray(); return view('index', compact('categories')); I want to make the names of categories as clickable links when user click on a categoey he will go to single page where all the subcategories(from sub categories table) of that particular clicked category should shown

15th November, 2017

saadat_2003 left a reply on Search In Laravel 5.5 • 6 months ago

any one help me as I have displayed categories(categories table) name on index using index function , $categories = Category::all()->toArray(); return view('index', compact('categories')); I want to make the names of categories as clickable links when user click on a categoey he will go to single page where all the subcategories(from sub categories table) of that particular clicked category should shown

saadat_2003 left a reply on Search In Laravel 5.5 • 6 months ago

thanks ,I have started working ,will get back you soon

14th November, 2017

saadat_2003 left a reply on Search In Laravel 5.5 • 6 months ago

I have categories for cars in database and want to search cars on the basis of categories

saadat_2003 started a new conversation Search In Laravel 5.5 • 6 months ago

I want to add search form in my laravel 5.5 website

2nd November, 2017

saadat_2003 left a reply on Convert Html To Aravel • 6 months ago

thanks

saadat_2003 started a new conversation Convert Html To Aravel • 6 months ago

Kindly help to convert html template to laravel

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.