The appearance of the added category in “user services list” page
I just added a category services(the category name: Like) , but when I go to services list (in user panel), more categories appear before the Like category.
Please see this video for a better understanding of my problem:
Serviceslist.blade.php codes(in views folder) :
@extends('user.layouts.master')
@section('site_title', 'Service List')
@section('page_title')
<i class="fa fa-list-ol"></i> @lang('slide.serviceslist')
@endsection
@section('body')
<div class="row">
<div class="col-md-12">
@foreach($categories as $category)
<div class="card">
<div class="card-header bg-dark text-white">
@if(!empty($category->category)) {{ $category->category->name }} @endif
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Sevice code</th>
<th>Service name</th>
<th>Price</th>
<th>min</th>
<th>max</th>
</tr>
</thead>
<tbody>
@php
$items = AppServicePrice::where('category_id', $category->category_id)->where('user_id', Auth::id())->get();
@endphp
@foreach($items as $item)
@if(!empty($item->service))
<tr>
<td> {{$item->service->id}}</td>
<td> {{$item->service->name}}</td>
<td>{{ $item->price }}</td>
<td>{{ $item->service->min }}</td>
<td>{{ $item->service->max }}</td>
</tr>
@endif
@endforeach
</tbody>
</table>
</div>
</div>
</div>
@endforeach
</div>
</div>
@endsection
and services list controller:
public function serviceList(){
$categories = ServicePrice::where('user_id', Auth::id())->distinct()-
>get(['category_id']);
return view('user.serviceList', compact('categories'));
}
javascript php laravel
add a comment |
I just added a category services(the category name: Like) , but when I go to services list (in user panel), more categories appear before the Like category.
Please see this video for a better understanding of my problem:
Serviceslist.blade.php codes(in views folder) :
@extends('user.layouts.master')
@section('site_title', 'Service List')
@section('page_title')
<i class="fa fa-list-ol"></i> @lang('slide.serviceslist')
@endsection
@section('body')
<div class="row">
<div class="col-md-12">
@foreach($categories as $category)
<div class="card">
<div class="card-header bg-dark text-white">
@if(!empty($category->category)) {{ $category->category->name }} @endif
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Sevice code</th>
<th>Service name</th>
<th>Price</th>
<th>min</th>
<th>max</th>
</tr>
</thead>
<tbody>
@php
$items = AppServicePrice::where('category_id', $category->category_id)->where('user_id', Auth::id())->get();
@endphp
@foreach($items as $item)
@if(!empty($item->service))
<tr>
<td> {{$item->service->id}}</td>
<td> {{$item->service->name}}</td>
<td>{{ $item->price }}</td>
<td>{{ $item->service->min }}</td>
<td>{{ $item->service->max }}</td>
</tr>
@endif
@endforeach
</tbody>
</table>
</div>
</div>
</div>
@endforeach
</div>
</div>
@endsection
and services list controller:
public function serviceList(){
$categories = ServicePrice::where('user_id', Auth::id())->distinct()-
>get(['category_id']);
return view('user.serviceList', compact('categories'));
}
javascript php laravel
Let's suppose$categoriescontain several categories, with empty names. Or maybe a magical thing.
– Vincent Decaux
Jan 3 at 14:11
I checked categories table in phpmyadmin, and there is just " Like" category.
– Amirhossein
Jan 3 at 19:13
add a comment |
I just added a category services(the category name: Like) , but when I go to services list (in user panel), more categories appear before the Like category.
Please see this video for a better understanding of my problem:
Serviceslist.blade.php codes(in views folder) :
@extends('user.layouts.master')
@section('site_title', 'Service List')
@section('page_title')
<i class="fa fa-list-ol"></i> @lang('slide.serviceslist')
@endsection
@section('body')
<div class="row">
<div class="col-md-12">
@foreach($categories as $category)
<div class="card">
<div class="card-header bg-dark text-white">
@if(!empty($category->category)) {{ $category->category->name }} @endif
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Sevice code</th>
<th>Service name</th>
<th>Price</th>
<th>min</th>
<th>max</th>
</tr>
</thead>
<tbody>
@php
$items = AppServicePrice::where('category_id', $category->category_id)->where('user_id', Auth::id())->get();
@endphp
@foreach($items as $item)
@if(!empty($item->service))
<tr>
<td> {{$item->service->id}}</td>
<td> {{$item->service->name}}</td>
<td>{{ $item->price }}</td>
<td>{{ $item->service->min }}</td>
<td>{{ $item->service->max }}</td>
</tr>
@endif
@endforeach
</tbody>
</table>
</div>
</div>
</div>
@endforeach
</div>
</div>
@endsection
and services list controller:
public function serviceList(){
$categories = ServicePrice::where('user_id', Auth::id())->distinct()-
>get(['category_id']);
return view('user.serviceList', compact('categories'));
}
javascript php laravel
I just added a category services(the category name: Like) , but when I go to services list (in user panel), more categories appear before the Like category.
Please see this video for a better understanding of my problem:
Serviceslist.blade.php codes(in views folder) :
@extends('user.layouts.master')
@section('site_title', 'Service List')
@section('page_title')
<i class="fa fa-list-ol"></i> @lang('slide.serviceslist')
@endsection
@section('body')
<div class="row">
<div class="col-md-12">
@foreach($categories as $category)
<div class="card">
<div class="card-header bg-dark text-white">
@if(!empty($category->category)) {{ $category->category->name }} @endif
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Sevice code</th>
<th>Service name</th>
<th>Price</th>
<th>min</th>
<th>max</th>
</tr>
</thead>
<tbody>
@php
$items = AppServicePrice::where('category_id', $category->category_id)->where('user_id', Auth::id())->get();
@endphp
@foreach($items as $item)
@if(!empty($item->service))
<tr>
<td> {{$item->service->id}}</td>
<td> {{$item->service->name}}</td>
<td>{{ $item->price }}</td>
<td>{{ $item->service->min }}</td>
<td>{{ $item->service->max }}</td>
</tr>
@endif
@endforeach
</tbody>
</table>
</div>
</div>
</div>
@endforeach
</div>
</div>
@endsection
and services list controller:
public function serviceList(){
$categories = ServicePrice::where('user_id', Auth::id())->distinct()-
>get(['category_id']);
return view('user.serviceList', compact('categories'));
}
javascript php laravel
javascript php laravel
asked Jan 3 at 14:07
AmirhosseinAmirhossein
327
327
Let's suppose$categoriescontain several categories, with empty names. Or maybe a magical thing.
– Vincent Decaux
Jan 3 at 14:11
I checked categories table in phpmyadmin, and there is just " Like" category.
– Amirhossein
Jan 3 at 19:13
add a comment |
Let's suppose$categoriescontain several categories, with empty names. Or maybe a magical thing.
– Vincent Decaux
Jan 3 at 14:11
I checked categories table in phpmyadmin, and there is just " Like" category.
– Amirhossein
Jan 3 at 19:13
Let's suppose
$categories contain several categories, with empty names. Or maybe a magical thing.– Vincent Decaux
Jan 3 at 14:11
Let's suppose
$categories contain several categories, with empty names. Or maybe a magical thing.– Vincent Decaux
Jan 3 at 14:11
I checked categories table in phpmyadmin, and there is just " Like" category.
– Amirhossein
Jan 3 at 19:13
I checked categories table in phpmyadmin, and there is just " Like" category.
– Amirhossein
Jan 3 at 19:13
add a comment |
1 Answer
1
active
oldest
votes
You need to order the categories in the controler with categories id to see the last categori as first.
public function serviceList(){
$categories = ServicePrice::where('user_id', Auth::id())->distinct()->orderBy( "category_id", "DESC" )->get(['category_id']);
return view('user.serviceList', compact('categories'));
}
I did it, but show : Method IlluminateDatabaseEloquentCollection::orderBy does not exist.
– Amirhossein
Jan 3 at 14:27
order by is before get()
– Unai Susperregi
Jan 3 at 14:31
But now, those additional categories are still appearing! With your help, the "Like" category came to the first.
– Amirhossein
Jan 3 at 14:33
Ok, then what is the problem? I cant see the video and you don't understand well. Your action is insert? list? if you are creating category you must send to other view, if you just want to see all the list I gave you the solution, if you want just show one categori use id or put ->fisrt() and use only one value.,
– Unai Susperregi
Jan 3 at 14:46
No, I added just one category, the category name is "Like", but in "services list" page, after this category, is showing more categories! but they don't have any names or services.
– Amirhossein
Jan 3 at 14:50
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54023925%2fthe-appearance-of-the-added-category-in-user-services-list-page%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to order the categories in the controler with categories id to see the last categori as first.
public function serviceList(){
$categories = ServicePrice::where('user_id', Auth::id())->distinct()->orderBy( "category_id", "DESC" )->get(['category_id']);
return view('user.serviceList', compact('categories'));
}
I did it, but show : Method IlluminateDatabaseEloquentCollection::orderBy does not exist.
– Amirhossein
Jan 3 at 14:27
order by is before get()
– Unai Susperregi
Jan 3 at 14:31
But now, those additional categories are still appearing! With your help, the "Like" category came to the first.
– Amirhossein
Jan 3 at 14:33
Ok, then what is the problem? I cant see the video and you don't understand well. Your action is insert? list? if you are creating category you must send to other view, if you just want to see all the list I gave you the solution, if you want just show one categori use id or put ->fisrt() and use only one value.,
– Unai Susperregi
Jan 3 at 14:46
No, I added just one category, the category name is "Like", but in "services list" page, after this category, is showing more categories! but they don't have any names or services.
– Amirhossein
Jan 3 at 14:50
add a comment |
You need to order the categories in the controler with categories id to see the last categori as first.
public function serviceList(){
$categories = ServicePrice::where('user_id', Auth::id())->distinct()->orderBy( "category_id", "DESC" )->get(['category_id']);
return view('user.serviceList', compact('categories'));
}
I did it, but show : Method IlluminateDatabaseEloquentCollection::orderBy does not exist.
– Amirhossein
Jan 3 at 14:27
order by is before get()
– Unai Susperregi
Jan 3 at 14:31
But now, those additional categories are still appearing! With your help, the "Like" category came to the first.
– Amirhossein
Jan 3 at 14:33
Ok, then what is the problem? I cant see the video and you don't understand well. Your action is insert? list? if you are creating category you must send to other view, if you just want to see all the list I gave you the solution, if you want just show one categori use id or put ->fisrt() and use only one value.,
– Unai Susperregi
Jan 3 at 14:46
No, I added just one category, the category name is "Like", but in "services list" page, after this category, is showing more categories! but they don't have any names or services.
– Amirhossein
Jan 3 at 14:50
add a comment |
You need to order the categories in the controler with categories id to see the last categori as first.
public function serviceList(){
$categories = ServicePrice::where('user_id', Auth::id())->distinct()->orderBy( "category_id", "DESC" )->get(['category_id']);
return view('user.serviceList', compact('categories'));
}
You need to order the categories in the controler with categories id to see the last categori as first.
public function serviceList(){
$categories = ServicePrice::where('user_id', Auth::id())->distinct()->orderBy( "category_id", "DESC" )->get(['category_id']);
return view('user.serviceList', compact('categories'));
}
edited Jan 3 at 14:31
answered Jan 3 at 14:17
Unai SusperregiUnai Susperregi
235313
235313
I did it, but show : Method IlluminateDatabaseEloquentCollection::orderBy does not exist.
– Amirhossein
Jan 3 at 14:27
order by is before get()
– Unai Susperregi
Jan 3 at 14:31
But now, those additional categories are still appearing! With your help, the "Like" category came to the first.
– Amirhossein
Jan 3 at 14:33
Ok, then what is the problem? I cant see the video and you don't understand well. Your action is insert? list? if you are creating category you must send to other view, if you just want to see all the list I gave you the solution, if you want just show one categori use id or put ->fisrt() and use only one value.,
– Unai Susperregi
Jan 3 at 14:46
No, I added just one category, the category name is "Like", but in "services list" page, after this category, is showing more categories! but they don't have any names or services.
– Amirhossein
Jan 3 at 14:50
add a comment |
I did it, but show : Method IlluminateDatabaseEloquentCollection::orderBy does not exist.
– Amirhossein
Jan 3 at 14:27
order by is before get()
– Unai Susperregi
Jan 3 at 14:31
But now, those additional categories are still appearing! With your help, the "Like" category came to the first.
– Amirhossein
Jan 3 at 14:33
Ok, then what is the problem? I cant see the video and you don't understand well. Your action is insert? list? if you are creating category you must send to other view, if you just want to see all the list I gave you the solution, if you want just show one categori use id or put ->fisrt() and use only one value.,
– Unai Susperregi
Jan 3 at 14:46
No, I added just one category, the category name is "Like", but in "services list" page, after this category, is showing more categories! but they don't have any names or services.
– Amirhossein
Jan 3 at 14:50
I did it, but show : Method IlluminateDatabaseEloquentCollection::orderBy does not exist.
– Amirhossein
Jan 3 at 14:27
I did it, but show : Method IlluminateDatabaseEloquentCollection::orderBy does not exist.
– Amirhossein
Jan 3 at 14:27
order by is before get()
– Unai Susperregi
Jan 3 at 14:31
order by is before get()
– Unai Susperregi
Jan 3 at 14:31
But now, those additional categories are still appearing! With your help, the "Like" category came to the first.
– Amirhossein
Jan 3 at 14:33
But now, those additional categories are still appearing! With your help, the "Like" category came to the first.
– Amirhossein
Jan 3 at 14:33
Ok, then what is the problem? I cant see the video and you don't understand well. Your action is insert? list? if you are creating category you must send to other view, if you just want to see all the list I gave you the solution, if you want just show one categori use id or put ->fisrt() and use only one value.,
– Unai Susperregi
Jan 3 at 14:46
Ok, then what is the problem? I cant see the video and you don't understand well. Your action is insert? list? if you are creating category you must send to other view, if you just want to see all the list I gave you the solution, if you want just show one categori use id or put ->fisrt() and use only one value.,
– Unai Susperregi
Jan 3 at 14:46
No, I added just one category, the category name is "Like", but in "services list" page, after this category, is showing more categories! but they don't have any names or services.
– Amirhossein
Jan 3 at 14:50
No, I added just one category, the category name is "Like", but in "services list" page, after this category, is showing more categories! but they don't have any names or services.
– Amirhossein
Jan 3 at 14:50
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54023925%2fthe-appearance-of-the-added-category-in-user-services-list-page%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Let's suppose
$categoriescontain several categories, with empty names. Or maybe a magical thing.– Vincent Decaux
Jan 3 at 14:11
I checked categories table in phpmyadmin, and there is just " Like" category.
– Amirhossein
Jan 3 at 19:13