PT-83

Member Since 1 Year Ago

Experience Points
23,320
Total
Experience

1,680 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
197
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.

  • Community Pillar

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

Level 5
23,320 XP
Apr
24
3 weeks ago
Activity icon

Replied to Trying To Move Login/Register Links From Welcome Page

Just went through this same exercise. Thanks for sharing the solution.

Feb
22
2 months ago
Activity icon

Replied to Spark: Bad Method Call

@vapordev

import use Spark\Billable; trait. And also in the class like follows.

class User extends Authenticatable
{
    use HasApiTokens;
    use HasFactory;
    use HasProfilePhoto;
    use Notifiable;
    use TwoFactorAuthenticatable;
    use Billable;
Feb
18
2 months ago
Activity icon

Commented on Attach And Validate Many-to-Many Inserts

Figured it out.Had to import use App\Models\Tag; now its functioning correctly. Using Laravel 8.

Activity icon

Commented on Attach And Validate Many-to-Many Inserts

When applying the following, I get this error Class 'App\Http\Controllers\Tag' not found. I understand it's searching for a controller, but I don't believe one was created for tags in this series?

 public function create()

    { 
        return view('articles.create', [
            'tags' => Tag::all()
        ]);
    }
Jan
15
4 months ago
Activity icon

Commented on Classes 101

Keywords:

Classes - can represent anything in your project. Naming convention is nouns (singular)

Functions - that are inside of classes are referred to as Methods.

Methods - a function inside a class.

Properties - are variables inside classes.

Objects - instance of the data structure defined by a class.

$this - calling of an object in the current method.

Dec
29
4 months ago
Activity icon

Replied to Is My Code Enough!!

In learning to code we often get overwhelmed with all the complexity at times. It's not easy that's for sure. Sometimes we overlook silly things and make mistakes. The point is ask questions when your stuck and try to wrap your head around what's happening. I would suggest in future posts to include some code, That way more experienced members can get a better idea of that you are asking help with and can suggest better ways of doing things.

Activity icon

Replied to Showing User Posts

@michaloravec I am following the laravel from scratch series and copied a component to use for the grid styling yes. I completely overlooked that the code was posted 3 times in a row, didn't even cross my mind.

I however do not appreciate your bottom half response specifically "it's like you have a problem with 1+3.

This is really ridiculous'.

I don't need you to belittle me with your snarky remark. Please take a hike.

Activity icon

Started a new Conversation Showing User Posts

Hi all, I am struggling to solve this issue. I am basically trying to show a view which is a user created post. This post belongsTo this user and the user who created it should only see this post.

Here is the code I have so far. Currently, I have the html/CSS setup to showcase 3 posts in a grid. I am seeing the same post over and over instead of each post created. For example, post 1, 1, 1 rather than post 1, 2, 3.

Any help on this would be great.

PostController

 public function index()
    {
        $posts = Post::latest()->get();
         
        return view('posts.index', compact('posts')); 
    }

  
    public function create()
    {
        
        return view('posts.create');
    }

  
    public function store(Request $request)
    {
        Post::create($this->post());

        return redirect()->back();
    }

   
    public function show(Post $post)
    {
        
        return view('posts.show', compact($post)); 
    }

   
    public function edit(Post $post)
    {
        return view ('posts.edit');
    }

   
    public function update(Request $request, Post $post)
    {
        $post->update($this->post()); 

        return redirect(route('posts.show', $post));
    }

    
    public function post()
    
    {
        request()->validate([
            'title' => 'required|min:5',
            'date' => 'required',
            'file' => 'nullable|file',
            'body' => 'required|min:5',
        ]);
    }

}

UserModel

 public function posts()
    {
        return $this->hasMany(Post::class); 
    }

PostModel

public $guarded = [];

    public function user()
    {
     return $this->belongsTo(User::class);
    }

Index.blade

  @foreach ($posts as $post)
            
        
 <div class="blogs bg-white mr-5">
     <img src="{{ $post->file }}" class="">
     <div class="p-5">
    <h1 class="text-2xl font-bold text-green-800 py-2">{{ $post->title }}</h1>
     <p class="bg-white text-sm text-black">{{ $post->body }}</p>
     <a href="{{ route('posts.show', $post) }}" class="py-2 mt-4 px-6 text-white bg-green-500 inline-block rounded">Read More</a>
     </div>
 </div>


 <div class="blogs bg-white mr-5">
    <img src="{{ $post->file }}" class="">
    <div class="p-5">
        <h1 class="text-2xl font-bold text-green-800 py-2">{{ $post->title }}</h1>
    <p class="bg-white text-sm text-black">{{ $post->body }}</p>
    <a href="{{ route('posts.show', $post) }}" class="py-2 mt-4 px-6 text-white bg-green-500 inline-block rounded">Read More</a>
    </div>
</div>

<div class="blogs bg-white mr-5">
    <img src="{{ $post->file }}" class="">
        <div class="p-5">
            <h1 class="text-2xl font-bold text-green-800 py-2">{{ $post->title }}</h1>
            <p class="bg-white text-sm text-black">{{ $post->body }}</p>
            <a href="{{ route('posts.show', $post) }}" class="py-2 mt-4 px-6 text-white bg-green-500 inline-block rounded">Read More</a>
        </div>
        </div>
    </div>
</div>
</div>


@break
@endforeach
Dec
23
4 months ago
Activity icon

Replied to PHP Tinker Factory Error

Same error is occuring when using

$this->faker->image(storage_path('img'),400,300, null, false)

InvalidArgumentException with message 'Cannot write to directory "/Users/paolo/Documents/code/famijam2/storage/img"'

Activity icon

Replied to PHP Tinker Factory Error

@nakov thanks I looked at that thread and changed the code as follows:

 public function definition()
    {
        return [
            'user_id' => \App\Models\User::factory(),
            'title' => $this->faker->sentence,
            'date' => $this->faker->date,
            'file' => $this->faker->image('public/storage/img',400,300, null, false), 
            'body' =>$this->faker->paragraph,
        ];
    }

However, I am getting InvalidArgumentException with message 'Cannot write to directory "public/storage/img"' error message.

Looking at my public->storage folder I see the sym link arrow, but I don't see the img folder. Do I have to manually create the img folder?

Activity icon

Started a new Conversation PHP Tinker Factory Error

Hi all, I'm tyring to create faker posts using tinker I get the following error message:

InvalidArgumentException with message 'Source and target directories must differ.'

Factory

public function definition()
    {
        return [
            'user_id' => \App\Models\User::factory(),
            'title' => $this->faker->sentence,
            'date' => $this->faker->date,
            'file' => $this->faker->file,
            'body' =>$this->faker->paragraph,
        ];
    }

In tinker I am running this command Post::factory()->count(5)->create();

Any idea on how to solve this?

Dec
17
4 months ago
Activity icon

Replied to How To Accept A Nullable Field - Form

Yes, I added after migrations. re-ran migration and works perfectly!

Activity icon

Started a new Conversation How To Accept A Nullable Field - Form

Hi all,

I have a database table with certain fields that are required. However, on the contact form, there is a number field I would like to make nullable. However, when I submit the request I get cannot make the number nullable error.

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'number' cannot be null

Any idea how to accomplish this?

public function up()
    {
        Schema::create('contacts', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->integer('number')->nullable();
            $table->string('email');
            $table->longText('body');
            $table->timestamps();
        });
    }
  public function store(Request $request)
    {
        $data = request()->validate([
            'name'=> 'required|min:5',
            'number'=> 'nullable|number',
            'email'=> 'required|email',
            'body'=> 'required|min:5',
        ]);
Nov
23
5 months ago
Activity icon

Replied to Laravel 8 From Scratch?

Thanks for the reply. I think my frustration boils down to a few things.

The previous boilerplate used @extends and @yield etc. Whilst these still exist, if you want to switch to the new way then there is some learning curve, which is NOT covered by the components videos...

Also all the tailwind <x-guest-layout> and <x-slot> tags are confusing to me. Perhaps rather a new Laravel series, maybe something detailing the above would be beneficial. I got used to the Laravel 7 way of building, now it feels I'm back to square one. I can't even get views to render without Undefined variable: slot

I did figure it out, but it would be helpful if a quick video on this was available so others don't get stuck.

Nov
22
5 months ago
Activity icon

Started a new Conversation Laravel 8 From Scratch?

I think it may be beneficial to create a new Laravel from scratch series specifically focusing on Laravel 8 and all the changes. I for one would benefit a lot from such a series, and I'm sure others too. Are there any plans to do so?