saadat_2003

saadat_2003

Member Since 1 Year Ago

Experience Points 1,010
Experience
Level
Lessons Completed 3
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

02 Jul
4 months ago

saadat_2003 started a new conversation How To Delete Unchecked Checkboxes In Laravel

I have displayed checkboxes of subjects in laravel.In which some checkboxes are already checked ,come from database.When any checkbox is checked the new subject is added in database. The actual problem is that there are other subjects checkboxes that are not saved in database. The issue to resolve is that,when user uncheck any checkbox of subject which is saved in database should be deleted from database

In blade

@foreach($grades as $grade) {{$grade->name}}
    @foreach($grade->subject as $subject)
  •                                         {!!Form::checkbox('check_list[]',$grade->id.'-'.$subject->id,$yes,['class'=>''])!!} <label class="label-tex">{{$subject->name}}</label>
                                        </li>
                                    @endforeach
                                </ul>
                            </fieldset>
                        @endforeach 
    

    in Controller

    if($request->check_list){ $user_id = auth()->user()->id; $i = 0; $j = 0;

                    foreach ($request->check_list as $data) {
                        $array1[$i] = explode('-', $data);
                        $i++;
                    }
    
                    foreach ($array1 as $j => $data1) {
    
                        $hasSubject = UserSubject::where('user_id', $user_id)->where('subject_id', $data1[1])->where('grade_id', $data1[0])->first();
    
                        if(is_null($hasSubject)) {
    
                            $user_subjects = new UserSubject();
                            $user_subjects->user_id = $user_id;
                            $user_subjects->grade_id = $data1[0];
                            $user_subjects->subject_id = $data1[1];
                            $user_subjects->status = 1;
                            $user_subjects->created_at = date("Y-m-d H:i:s");
                            $user_subjects->updated_at = date("Y-m-d H:i:s");
                            // dd($user_subjects);
                            $user_subjects->save();
    
                            $j++;
    
    
                        }
    
                    }
    
12 Apr
7 months ago

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

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

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]);
        }

29 Mar
7 months ago

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

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>
24 Nov
11 months ago

saadat_2003 left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage

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

@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

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

@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

21 Nov
11 months ago

saadat_2003 left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage

@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

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

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

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

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)

20 Nov
11 months ago

saadat_2003 left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage

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

@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

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

17 Nov
11 months ago

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

@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

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

@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

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

@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

@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

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

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

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

@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

16 Nov
11 months ago

saadat_2003 left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage

@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

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

15 Nov
11 months ago

saadat_2003 left a reply on Search In Laravel 5.5

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

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

14 Nov
1 year ago

saadat_2003 left a reply on Search In Laravel 5.5

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

I want to add search form in my laravel 5.5 website

02 Nov
1 year ago

saadat_2003 started a new conversation Convert Html To Aravel

Kindly help to convert html template to laravel