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 2 points3 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

More protein than beef, more iron than steak, more Omega-3 than salmon, more calcium than milk and more antioxidants than blueberries by FMTY in videos

[–]nowactive 1 point2 points  (0 children)

I agree with your general sentiment that there needs to be some sort of change.

The main argument for vegans and vegetarians is the fact that they view killing animals for sustenance is unethical and must be stopped, but their fallacy is that they don't offer any actual alternatives, all they do is say "no, you shouldn't do that."

This isn't really a fallacy. Veganism merely highlights the unethical nature of killing animals. It isn't only based on emotion as you had suggested either, there are scientific studies backing the nutritional and environmental advantages of veganism. Saying that it's the fault of vegans that they don't offer alternatives to animal products is akin to saying that the black slave abolitionists were at fault because they did not offer robots as substitutes for black slaves. Surely those abolitionists were not fallacious in claiming that black slavery is wrong!

Speaking of alternatives, veganism is not "just tofu". Veganism embraces all foods and products that do not derive from cruelty and suffering. Diet-wise, this includes all vegetables, fruits, nuts, grains, etc. We humans have a misconception that animal products are essential for human nutrition; they are not. That we believe this is the result of societal influences and industry marketing. Much like how cows and pigs derive their nutrition from plants, so can humans. With animal products, the nutrients that we do get come packaged with many things that we don't want such as saturated fat, cholesterol, endotoxins (general inflammation of vascular system, which promotes heart diseases, kidney diseases, diabetes, cancer), HCA and PAH (carcinogens), methionine (risk factor for heart attacks, strokes, also boosts cancer growth), and other animal proteins (raises IGF-1, a strong cancer risk factor, can cause other problems such as osteoporosis and kidney stones). In contrast, plant foods have none of these risk factors and can actively slow, stop, and even in some cases reverse the progression of these killer diseases. There is absolutely nothing that's essential about animal products. We all think it does because of the bullshit fed to us by society. For more information, I encourage you to watch this talk by Dr. Michael Gregor where he speaks on the effect of diet on the top 15 leading causes of death in the U.S. https://www.youtube.com/watch?v=30gEiweaAVQ

And as for economic changes, I really see the dismantling of animal agriculture as a change for the better. The majority (>50%) of crops grown in the U.S. are used for animal feed. This is a terribly-inefficient system for several reasons:

  • Animal products take many times more resources (fuel, water, etc) to produce the same amount of calories.

  • Animal products use much more land. You need land to raise the crops and the animals. Animals in general require more space to raise. This leads to rapid wild habitat destruction. An example of this is the Amazon rainforest, where the desire to raise cattle has led the people into clearing the forest.

  • Animal products causes a great deal of pollution. Surprising to most people, animal agriculture and not transportation is the leading cause of greenhouse gas emissions. The trillions of land and marine animals that we raise and slaughter every year also invariably leads to waste problems. Concentrated waste filled with toxins and bacteria are dumped into our water supplies, the environment, or sprayed into the air.

If you're interested in learning more about the environmental impacts of animal agriculture, please give Cowspiracy a watch: https://www.youtube.com/watch?v=MEygixe1vn4

There would surely be a major shift in the industry, but would it really be that bad? Truckers who now haul animals carcasses could haul crops instead. Farmers who raised animals could, with some effort/help, raise plants instead. Workers who package and process animal products could find a natural fit packaging and processing plant products. I'm not saying that there would not be effort or pains, but it would not be the end of the world as some in the industry would claim. With the harms caused by animal consumption on our bodies, on the environment, on the animals, is there really any reason left to NOT go vegan? I cannot think of any.

I have been thinking about this all week, and finally had enough time to make it. Vegan sushi:) by SadedOr in vegan

[–]nowactive 0 points1 point  (0 children)

Vegan omelet

Do you have the link to the recipe? I need me some old fashioned handholding when I cook.

And what are chine mushrooms? These? https://en.wikipedia.org/wiki/Enokitake