Authorization Basics | Laravel 10 Tutorial #22

Authorization Basics | Laravel 10 Tutorial #22

Yelo Code

10 месяцев назад

5,874 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@nezseco4719
@nezseco4719 - 26.12.2023 11:24

Can someone tell me how the auth()->id()
Works?,

Ответить
@SiFu_Max
@SiFu_Max - 24.12.2023 21:40

Hey it's me again I still get the "SQLSTATE[HY000]: General error: 1364 Field 'user_id' doesn't have a default value" Error but I set in the "Idea.php" Model I set it to fillable.

My Code for a reverence:

Idea.php:

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Idea extends Model
{
use HasFactory;

protected $fillable = [
'user_id',
'content',
'like',

];

public function comments()
{
return $this->hasMany(Comment::class);
}

}


IdeasController store method:

public function store()
{

$validated = request()->validate([
'content' => 'required|min:5|max:240'
]);

$validated['auth_id'] = auth()->id();


Idea::create($validated);

return redirect()->route('ideas.dashboard')->with('success', 'Idea created successfully');

}

And THANKS A LOT for the help and this good cours

Ответить
@rifaierazak4322
@rifaierazak4322 - 21.12.2023 15:18

Any suggestions on why when I click on post comment, it doesn't show the success message?

Ответить
@darshanbhandary
@darshanbhandary - 17.12.2023 17:52

What about comment section?
how to keep track about comments added by different users on a idea?

Ответить
@ralphallenlamozo8428
@ralphallenlamozo8428 - 18.11.2023 17:11

what theme are you using?

Ответить
@jaylylz1921
@jaylylz1921 - 10.11.2023 14:31

why am i getting this error "Attempt to read property "name" on null" when echoring the user name on {{$idea->user->name}} in the blade file.

Ответить
@aman4069
@aman4069 - 28.10.2023 15:17

Is it possible that when I write the same code as you, I get an error but you not. After being frustrated, I tried to write the same code, and it's worked :)

Ответить
@archiealvarado8831
@archiealvarado8831 - 19.10.2023 11:07

exercise done hehe @if(auth()->id() == $idea->user_id) put to the buttons hehe

Ответить
@user-qr8dj1qx8g
@user-qr8dj1qx8g - 19.09.2023 18:14

Laravel is simple because of YOU! Thanks a lot.

Ответить
@ousssika5359
@ousssika5359 - 15.09.2023 17:20

thanks for your cours man , your a big help , don't stop sooner or later you will have more subs ,

Ответить