ziben69

ziben69

Member Since 1 Year Ago

Experience Points
6,260
Total
Experience

3,740 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
1
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

Level 2
6,260 XP
Mar
03
2 months ago
Activity icon

Replied to Pass Variable To Relationship Controller

Yes, always the same :)

Activity icon

Replied to Pass Variable To Relationship Controller

Ok thanks, but how can I add tax to price now? :)

Activity icon

Started a new Conversation Pass Variable To Relationship Controller

Hello guys, how can I pass variable to other controller?

I have two tables Products and Orders in relation one to many. In Products table I have column Price and this one I would like to have in OrderController. In my OrderController's function store I have product_id:

public function store(Request $request)
{
$order = new Order();
...
$order->product_id = $request->input('product_id');
...
}

How can I pass price value (from product table) to OrderController if I have product_id. After this I need to calculate this price with tax and store to DB. Thanks for help

Feb
21
3 months ago
Activity icon

Replied to Laravel Route Conflict

In fact thank you.

Activity icon

Replied to Laravel Route Conflict

And I think I found a conflict :)

Route::get('/{id}', '[email protected]');~

I changed to:

Route::get('catalog/{id}', '[email protected]');

and it worked as it should;

the reason is probably:

Route::get('/{slug}', '[email protected]');~
Activity icon

Replied to Laravel Route Conflict

@sinnbeck

However, reordering didn't help. The subpage /catalog is now displayed to me, but the subpages /{slug} are not displayed to me.

Let me add complete routing and if you can, take a look again.

Feb
20
3 months ago
Activity icon

Replied to Multi Level Paginator

@sti3bas Thank you. You're right. I got stuck in my code instead of reaching for the simple solution :/

Activity icon

Replied to Multi Level Paginator

but now it displays my pagination as many times as I have categories in the database.

Activity icon

Started a new Conversation Multi Level Paginator

Hello guys, I have 2 tables categories and products. In category.blade.php I would like to paginate products. In my CategoryController I have:

        $categories = Category::where('visible',1)->orderBy('order', 'asc')->with(['products'=>function($q) use ($id) {
            $q->where('category_id', $id)->where('visible', 1)->orderBy('order', 'asc')->paginate(8);
        }])->get();

in view I have:

@foreach($categories as $category)
@foreach($category->products as $product)
@php
    $productsPaginator = $product->paginate(8);
@endphp
<div class="col-sm-6 col-md-4 col-lg-3 ftco-animate">
    <div class="product">
        <h3><a href="#">{{ $product->title }}</a></h3>
    </div>
</div>
@endforeach
@endforeach
{{ $productsPaginator->links() }}

In DB are 56 products, but each of them have other category_id. It works, but:

{{ $productsPaginator->links() }}

display to me 7 tabs from 1 to 7 - each tabs 8 products. Not quite correctly, it should display as many tabs as there are products in a given category, not as many as there are all. For example, in the category I have 20 products, it should display 3 tabs, not 7. At the moment an error pops up after clicking 4 tabs.

Can someone help? So much thanks.

Activity icon

Replied to How To Display Attributes Assigned To Products In Category View

@snapey I need to display product attributes for specific categories. He proposed a solution displaying all attributes from the database. I have 3 categories, each of these categories has products that have their own attributes. Not all attributes are in all categories. Do you have any idea?

Feb
19
3 months ago
Activity icon

Started a new Conversation How To Display Attributes Assigned To Products In Category View

Hello, I have problem with relationship query. I have in my show.blade.php (category):

 @foreach( $attributes as $attribute)
 {{ $attribute->title }}
@endforeach

and in CategoryController function show:

   $attributes = Attribute::where('visible',1)->orderBy('order', 'asc')->with(['products'=>function($q) use ($id) {
            $q->where('category_id', $id)->where('visible', 1)->orderBy('order', 'asc')->get();
        }])->get();

My relationships look like: Category 1:N Product Product N :(pivot product_attribute): N Attribute

I need to display attributes assigned to products. For example product 1 have attributes A, B, C, product 2 have attribute B, E and lets display A,B, C, E.

Activity icon

Replied to Laravel | Displaying Products In A Particular Category

Oh, in fact, I didn't notice ... Thank you

Activity icon

Started a new Conversation Laravel | Displaying Products In A Particular Category

Hello guys, how can I display records from products table (each product have category_id) in category show view?

I have something like that Controller function:

   public function show(CategoryRepository $catRepo, $id)
    {
        $category = $catRepo->find($id);

        $categories = Category::where('visible',1)->orderBy('order', 'asc')->with(['products'=>function($q) {
            $q->where('category_id',3)->where('visible', 1)->orderBy('order', 'asc')->get();
        }])->get();

        return view('pages.category.show', [
            'category' => $category,
            'categories' => $categories,
        ]);
    }

$categories query gives me good result but category_id is set to 3. How can I replace this id with the one passed from the view to the controller?

In my view I pass ID like that:

<a href="{{ URL::to('/category/' . $category->id) }}">Example</a>

and inspect gives me result localhost/category/3 so its. After click on button redirects to localhost/category/3. So only how to display products where:

category_id is $category = $catRepo->find($id);

When I try put $category or $id to query an error appears: Undefined variable

Activity icon

Replied to Laravel - Display Only 3 Records From Relationship

Better, but it gives me only 3 products in general, and I need 3 products for each category. Do you have any ideas?

Activity icon

Started a new Conversation Laravel - Display Only 3 Records From Relationship

Hello guys,

In my controller I have query:

$categories = Category::where('visible',1)->orderBy('order', 'asc')->with(['products'=>function($q) {
    $q->where('visible', 1)->orderBy('order', 'asc')->get()->take(3);
}])->get();

when I try to display 3 product from categories it doesn't work. It display all products...

My view:

@foreach($categories as $category)
    <div class="sidebar-box-2">
        <h2 class="heading mb-4"><a href="#">{{ $category->title }}</a></h2>
        <ul>
        @foreach( $category->products as $product)
            <li><a href="#">{{ $product->title }}</a></li>
        @endforeach
</ul>
    </div>
@endforeach

How can I display only 3 products from category? Thanks so much!

Activity icon

Started a new Conversation Laravel Pagination

Hello guys, I have query:

$categories = Category::where('visible',1)->orderBy('order', 'asc')->with(['products'])->paginate(3);;

in my view:

@foreach($categories as $category)
<div class="sidebar-box-2">
    <h2 class="heading mb-4"><a href="#">{{ $category->title }}</a></h2>
    <ul>
    @foreach( $category->products as $product)
        <li><a href="#">{{ $product->title }}</a></li>
    @endforeach
    {{ $category->products->links() }}
    </ul>
</div>
@endforeach

Relationship: Category 1:N Product

How can I paginate products in categories view??

Feb
18
3 months ago
Activity icon

Replied to Displaying Data From The Database - Complex Query

But what when I have relationship like this:

Catalog 1:N Category 1:N Product N:N Attribute

if I do:

public function attributes()
    {
        return $this->hasManyThrough('Attribute', 'Product');
    }

in Catalog model I have error:

Call to undefined relationship [attributes] on model [App\Models\Category].

this is probably because there is still a category table along the way. There is only one intermediate table in the documentation.

Activity icon

Replied to Displaying Data From The Database - Complex Query

Thanks, almost good. Now it display attributes to me as many times as there are products, and I need display only once

Activity icon

Started a new Conversation Displaying Data From The Database - Complex Query

Hello guys,

I have 3 tables in relationship:

Categories 1:N Products N:N Attributes

how can I display something like this:

Show attributes where category id = ?

I have in my view sidebar:

@foreach($categories as $category)
<div class="sidebar-box-2">
        <h2 class="heading mb-4"><a href="#">{{ $category->title }}</a></h2>
    <ul>
        @foreach( $category->product as $product)
        <li><a href="#">{{ $product->title }}</a></li>
        @endforeach                    
    </ul>
</div>
@endforeach

but it display only product from category. I would like to display attributes of products here.

In my controller I have this query:

$categories = Category::where('visible',1)->orderBy('order', 'asc')->with(['products'])->get();

Thanks for help

Activity icon

Replied to Laravel Route Conflict

@sinnbeck that's it :D Thanks

Activity icon

Started a new Conversation Laravel Route Conflict

Hello guys,

I have route:

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

and second route:

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

When I try to go in localhost/catalog I get an error indicating the use of a function from PageController called "show" and should use the "index" function of the CatalogController.

How can I fix it?

Activity icon

Replied to Put Values From Database To Select Box - Edit.blade.php View

I have model Product in relationship with Attribute model many to many. In one to many relationship your solutin works.

I have tables: products, attributes and product_attribute.

and it show all attributes in select box but in edit.blade.php should display all but the selected ones can be marked and are not. So probably problem is in product_attribute table?

Activity icon

Started a new Conversation Put Values From Database To Select Box - Edit.blade.php View

Hello guys, I have create.blade.php view:

<div class="form-group">
        <label for="attributes">Attributes:</label>
        <select name="attributes[]" multiple class="select2-demo form-control" id="attributes">
              @foreach ($attributes as $attribute)
              <option value="{{ $attribute->id }}">{{ $attribute->title }}</option>
              @endforeach
        </select>
</div>

and it is working, but when I go to my edit.blade.php view where I have:

<div class="form-group">
        <label for="attributes">Attributes:</label>
        <select name="attributes[]" multiple class="select2-demo form-control" id="attributes">
              @foreach ($attributes as $attribute)
              <option value="{{ $attribute->id }}"@if($product->attribute_id == $attribute->id)  @endif>{{ $attribute->title }}</option>
              @endforeach
        </select>
</div>

doesn't display to me saved in the database. If I choose any attributes from the box and save everything is ok. It's just about displaying the attributes assigned to the product from the database. Anyone can help?

Jan
27
4 months ago
Activity icon

Started a new Conversation Laravel 5.8 + VueJS2 | Json In The Page Code

Hello guys.

I have small problem. Instead of displaying the template contents from the component, it displays json to me (but only in the console after clicking on inspection). I have no result in the view.

My Package.Json:

    "axios": "^0.18.0",
        "bootstrap": "^4.0.0",
        "cross-env": "^5.2.0",
        "jquery": "^3.2",
        "laravel-mix": "^4.0.7",
        "lodash": "^4.17.5",
        "popper.js": "^1.12",
        "resolve-url-loader": "^2.3.1",
        "sass": "^1.15.2",
        "sass-loader": "^7.1.0",
        "vue": "^2.5.17",
        "vue-template-compiler": "^2.6.8",
        "vuedraggable": "^2.19.1"

My component:

<template>

<div class="row">
 <div class="col-md-12">
        <div class="table-responsive">
        <table class="table table-sm table-striped">

    <draggable :list="navbarNew" handle=".my-handle" animation="500" tag="tbody" @change="update">

        <tr v-for="(navbar, index) in navbarNew">
            <td>{{ navbar.id }}</td>
            <td v-if="navbar.title !== null">{{ navbar.title }}</td>
            <td v-else>-</td>
            <td v-if="navbar.type === 'main'">Main menu</td>
            <td v-else>Sidebar</td>
            <td v-if="navbar.visible !== null && parseInt(navbar.visible, 10) === 1">Yes</td>
            <td v-else>No</td>
            <td>{{ navbar.order }}</td>
            <td><a :href="'edit/' + navbar.id" class="btn btn-primary btn-sm" style="width: 30px; height:30px;"><i class="fa fa-pencil" aria-hidden="true"></i></a>
                <a class="btn btn-dark btn-sm" style="cursor:move; width: 30px; height:30px;" ><i class="fa fa-arrows my-handle" aria-hidden="true" style="color:#fff;"></i></a>
    </td>
    </tr>
    </draggable>

    </table>
               </div>
    </div>
    </div>
</template>

<script>
    import draggable from 'vuedraggable'
    export default {
        components: {
            draggable
        },

        props: ['navbar'],

        data() {
            return {
                navbarNew: this.navbar,
                csrf: document.head.querySelector('meta[name="csrf-token"]').content
            }
        },
        methods: {
            update() {
                this.navbarNew.map((navbar, index) => {
                    navbar.order = index + 1;
                })

                axios.put('/navbar/updateAll', {
                    navbar: this.navbarNew
                }).then((response) => {
                    // success message
                })
            }
        },
        filters: {
            truncate: function(value) {
                if (value && value.length > 20) {
                    value = value.substring(0, 17) + '...';
                }
                return value
            }
        },
        mounted() {
            console.log('Component mounted.')
        }
    }
</script>

Here is app.js:

import Vue from 'vue'
import axios from 'axios'

Vue.prototype.$http = axios
require('./bootstrap');
window.Vue = require('vue');

Vue.component('navbar-table-draggable', require('./components/NavbarTableDraggable.vue').default);

and fragment of view:

 <navbar-table-draggable :navbar="{{ $navbar }}"></navbar-table-draggable>

in result I get after inspect (code inspection) JSON (no in console):

<div class="col-md-12>
<navbar-table-draggable :navbar="[{"id":1,"type":"main","title":"Test","created_at":"2020-01-27 18:17:34","updated_at":"2020-01-27 18:17:34","visible":1,"order":null}]"></navbar-table-draggable>
</div>

I don't have any errors, but my:

    mounted() {
            console.log('Component mounted.')
        }

doesn't work. It should display in my console message...

Can someone help? Thanks

Jan
26
4 months ago
Activity icon

Replied to Laravel 5.8| Downgrade JQuery Version From 3.3.1 To 3.2.1

Maybe I will write this way. Six months ago I wrote CMS in Laravel 5.8. I wanted to refresh his look and try to adapt the written HTML template to this project.

The problem is, I don't know why I don't want front-end. I am looking for a reason everywhere. In this order fell on JQuery.

I did as you wrote, but without any effects. :(

Activity icon

Started a new Conversation Laravel 5.8| Downgrade JQuery Version From 3.3.1 To 3.2.1

Hello guys,

I have been trying to reduce jquery from 3.3.1 to 3.2.1 all day. I have read half google.

I tried using npm to uninstall jquery and reinstall it.

I tried the composer.

I tried to manually change the version.

With no effect. I still have version 3.3.1.

I will only add that I was deleting the cache. I am asking for a hint.

I will just add that if I remove app.js, everything is beautiful, when I restore app.js, it stops. I also tried JQuery noConflict, but it also doesn't work. Bootstrap version is correct.

I have a template that uses boostrap 4.1.3 and JQuery version 3.2.1. Much does not work without this change. Thank you!