2 Best Reply Awards

  • Member Since 3 Years Ago
  • 875 Lessons Completed
  • 2 Favorites

20th November, 2017

design-studio left a reply on How To Dynamically Set Hidden Attribute, When Passing Model Data To Vue Components? • 1 day ago

You said:

I tried to limit the passed data by using the $hidden-attribute on the model, but this doesn't work in all use cases. What does it mean ? what cases ? It should work for all attributes, including relationships.

You can also user the opposite $visible property or hiding/showing them at runtime. See: 'hiding-attributes-from-json' in the doc

19th November, 2017

design-studio left a reply on Keeping Correct Data On Views • 2 days ago

While sharing variables across views is great (as explained), I think in the case you presented here I would rather delete the user and redirect either back or to the index, and let the index method deal with getting the users.

 public function softDelete(User $user)

    // redirect back
    return redirect()->back();

    // OR redirect to the [email protected], you started with
    return redirect()->route('home.index')
    return redirect()->to('/')

15th November, 2017

design-studio left a reply on How Can I Solve This 404 Not Found Error Even When Route Exist • 6 days ago

  1. You said your route list results in: POST | mappy | location | App\Http\Cont rollers\[email protected] | web,auth there is space in the middle of the word Cont rollers. I assume it is a mistake done when pasting the text here, but check it out.
  2. Are you running the command in the or maybe in some sub-directory, for example ? if so js points to the wrong url and it won't work, and you'll have to create the url in the js using laravel, like you tried.

14th November, 2017

design-studio left a reply on Poly-polymorpic Relations? • 1 week ago

That looks OK to me. The pricesWhereType method, just like the prices doesn't return a collection. It returns a Illuminate\Database\Eloquent\Relations\MorphMany relation object. This objects delegates some methods to a \Illuminate\Database\Eloquent\Builder so you can use all the Builder methods to get what ever results you want. for example, to get all related retail prices use:


13th November, 2017

design-studio left a reply on Poly-polymorpic Relations? • 1 week ago

I think you should have a Price model, (with prices table) that will have fields for the price value and the price type, priceable_id and priceble_type. The type field will represent the different type possible (retail, advisory, sales etc.. ) Then all objects that needs to have prices will use a trait that will have methods to get the related prices models, and related prices models by type:

trait HasPrices {

     * All related prices
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
    public function prices() {
        return $this->morphMany(\App\Price::class, 'priceable');

     * Related prices by type
     * @param string $type
     * @return \Illuminate\Database\Eloquent\Builder
    public function pricesWhereType($type) {
        return $this->prices()->where('type', $type);


You can even define scope on the Price model and use in the traitto make it more readable.

Does that work ?

design-studio left a reply on Dynamic Routes • 1 week ago

I think you have an exclamation mark where there shoudn't be one. That is it should be if($community) instead of if(!$community)

design-studio left a reply on Laravel Eloquent Order Posts By Created_at And Keep Sticky Post On Top • 1 week ago

You can chain 2 orderBymethods. first order by sticky_post then order by created_at. So it will look like this:

public function index(PostFilter $filter)
    return Post::with(['author', 'category', 'tags'])
        ->paginate(request()->perPage ? request()->perPage : 15);

note: you can also use the latest method. check the docs for Ordering, Grouping, Limit, & Offset

6th February, 2017

design-studio started a new conversation Visual Studio Code • 9 months ago

Hi Jeffrey. I was wondering if you tried the "Visual Studio Code"? What's your take on it? Also, if you liked it, and since I like simple concise way you explain things, I was wondering if you could give a run of your preferred setup for this editor.


Edit Your Profile

Want to change your profile photo? We pull from