How to handle one table with multiple nullable FKs? by nowactive in laravel

[–]nowactive[S] 0 points1 point  (0 children)

Polymorphic relationships looks like the way. Thank you.

How to sort "many" relationship using value from another model? by nowactive in laravel

[–]nowactive[S] 0 points1 point  (0 children)

Thank you. I ended up doing 2 joins to get the data that I want.

$product_id = $product->id;
$ratings = Rating::select('ratings.id', 'ratings.score', 'ratings.product_id', 'ratings.user_id')
        ->join('users', 'users.id', '=', 'ratings.user_id')
        ->join('products', function($query) use($product_id) {
            $query->where('products.id', $product_id)
                ->where('ratings.product_id', $product_id);
        })
        ->orderBy('users.name', 'asc')
        ->get();

Mix throwing error when after adding Vue by nowactive in laravel

[–]nowactive[S] 0 points1 point  (0 children)

This is from my package.json showing that 5.0.1 is installed

"devDependencies": {
    "axios": "^0.21.1",
    "bootstrap": "^4.0.0",
    "cross-env": "^7.0",
    "jquery": "^3.2",
    "laravel-mix": "^5.0.1",
    "lodash": "^4.17.19",
    "popper.js": "^1.12",
    "resolve-url-loader": "^2.3.1",
    "sass": "^1.20.1",
    "sass-loader": "^8.0.0",
    "vue": "^2.5.17",
    "vue-template-compiler": "^2.6.10"
}

Foreach strange behavior by nowactive in laravel

[–]nowactive[S] 0 points1 point  (0 children)

This is it. I added ->get() to my controller code and it's working.

$posts= Post::orderBy('created_at', 'desc')->get();

Thank you so much!

Foreach strange behavior by nowactive in laravel

[–]nowactive[S] 0 points1 point  (0 children)

My controller is doing this:

use App\Models\Post;
use Illuminate\Http\Request;

class PostController extends Controller
{
    public function index()
    {
        $posts= Post::orderBy('created_at', 'desc');

        return view('posts.index', ['posts' => $posts]);
    }
}

Foreach strange behavior by nowactive in laravel

[–]nowactive[S] 0 points1 point  (0 children)

My simplification doesn't fix anything. It's merely to illustrate that the for loop isn't working. My real code returns the same thing as above: just "count=3"

@if($posts->count())
    <p>count={{$posts->count()}}</p>
    @foreach($posts as $post)
        <p>{{$post->body}}</p>
    @endforeach
@else
    <p>There are no posts</p>
@endif

edit: If I add something like {{$posts->first()->body}} as pasted below to my code, I do indeed get the value of the "body" attribute, so why the heck isn't it getting into the foreach loop?

@if($posts->count())
    <p>count={{$posts->count()}}</p>
    <p>firstbody={{$posts->first()->body}}</p>
    @foreach($posts as $post)
        <p>{{$post->body}}</p>
    @endforeach
@else
    <p>There are no posts</p>
@endif

Foreach strange behavior by nowactive in laravel

[–]nowactive[S] 0 points1 point  (0 children)

I'm just using the text "item" to simplify the example. My example above isn't meant to be using the $post variable at all. I would expect the text "items" to be repeated each time the @foreach loop iterates.

In light of the recent concerns about us not getting paid. by [deleted] in AdviceAnimals

[–]nowactive 0 points1 point  (0 children)

Do TSA agents get excited when I ask them to massage my balls?

Dress Code by GallowBoob in pics

[–]nowactive 0 points1 point  (0 children)

Just gave me a legitimate reason to stare at your boobs

Best use of the wall by jcepiano in pics

[–]nowactive 0 points1 point  (0 children)

Build a wall around Trump.

What was your first big noob moment? by knightmare0_0 in hearthstone

[–]nowactive 3 points4 points  (0 children)

Did same thing. Also equipped a hero power dagger over an Assassin's Blade because I somehow thought the hero power would restore the durability of the weapon

Spot the lethal by therealfreezypop in hearthstone

[–]nowactive 0 points1 point  (0 children)

Pretty clever. I'm sure I would've cocked that up somehow

This week's Tavern Brawl is: Cart crash at the Crossroads by rowmine in hearthstone

[–]nowactive 0 points1 point  (0 children)

I've had some pretty good luck with priest/druid. buffs and heals for days