saadat_2003

Experience

800

0 Best Reply Awards

  • Member Since 1 Month Ago
  • 3 Lessons Completed
  • 0 Favorites

24th November, 2017

saadat_2003 left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage • 2 weeks 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 • 2 weeks 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 • 2 weeks 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 • 2 weeks 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 • 3 weeks 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 • 3 weeks 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 • 3 weeks 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 • 3 weeks 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 • 3 weeks 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 • 3 weeks 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 • 3 weeks 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 • 3 weeks ago

subcategory is table name?

saadat_2003 left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage • 3 weeks 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 • 3 weeks 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 • 3 weeks 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 • 3 weeks 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 • 3 weeks 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 • 3 weeks 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 • 3 weeks 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 • 3 weeks 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 • 3 weeks 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 • 3 weeks 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 • 3 weeks 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 • 3 weeks 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 • 3 weeks 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 • 3 weeks 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 • 3 weeks 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 • 4 weeks 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 • 4 weeks 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 • 1 month ago

thanks

saadat_2003 started a new conversation Convert Html To Aravel • 1 month ago

Kindly help to convert html template to laravel

Edit Your Profile
Update

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