jewishmoses

jewishmoses

Member Since 1 Month Ago

Experience Points
600
Total
Experience

4,400 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
2
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.

Level 1
600 XP
Oct
16
4 days ago
Activity icon

Replied to Cloudflare WAF And Or Xor Sqreen For Security?

@dr-bob Maybe it wasn't available at the time of your reply but it seems like you can turn off "Signup using disposable email" and "Block users connecting from TOR" with sqreen. They seem like a super good solution offering a lot more then Cloudflare.

Oct
11
1 week ago
Activity icon

Replied to How To Use Casts With Json Columns?

This Model::create(['slug->en' => 'Title']) will create this {"en":"Title"} I want it to use the slug cast (which it seems to ignore) and be {"en":"title"} @tisuchi hopefully this explains better

Activity icon

Replied to How To Use Casts With Json Columns?

@tisuchi Not sure how this is related

Activity icon

Started a new Conversation How To Use Casts With Json Columns?

I tried the following:

public $casts = [
    'slug->en' => Slug::class,
];

I didn't get any error, but it didn't set the slug as it should.

Model::create(['slug->en' => 'Title'])
Sep
30
2 weeks ago
Activity icon

Replied to How To Setup Laravel File Permission Once And For All

Yes, the group is also www-data and it's already within /etc/group still having issues

Sep
27
3 weeks ago
Activity icon

Started a new Conversation How To Setup Laravel File Permission Once And For All

I have followed this answer and did the following:

sudo chown -R my-user:www-data /var/www/domain.com/
sudo find /var/www/domain.com/ -type f -exec chmod 664 {} \;
sudo find /var/www/domain.com/ -type d -exec chmod 775 {} \;
sudo chgrp -R www-data /var/www/domain.com/storage /var/www/domain.com/bootstrap/cache
sudo chmod -R ug+rwx /var/www/domain.com/storage /var/www/domain.com/bootstrap/cache

Everything works fine, but whenever a directory is created by my-user and not www-data user, the webserver can't write to it (within the storage directory). Unless I rerun those commands after the folder has been created.

What should I do? other than running them again

Sep
11
1 month ago
Activity icon

Started a new Conversation How To Assert Paginations In Laravel?

I have a category model with the following method:

public static function index()
{
    return self::has('posts')->paginate(1);
}

My category controller:

public function index()
{
    $categories = Category::index();
    return view('categories.index', compact('categories'));
}

This is what I've tried:

$response = $this->get(route('categories.index'));
$response->assertViewHas('categories', Category::index());

This test fails for some reason:

Failed asserting that two objects are equal.

at tests/Feature/CategoryTest.php:38
    37|         $response->assertViewIs('categories.index');
  > 38|         $response->assertViewHas('categories', Category::index());

--- Expected
+++ Actual
@@ @@
                 'dispatchesEvents' => Array ()
                 'observables' => Array ()
                 'relations' => Array (
+                    'posts' => Illuminate\Database\Eloquent\Collection Object (...)
                 )
                 'touches' => Array ()
                 'timestamps' => true
Sep
05
1 month ago
Activity icon

Replied to Does FirstOrCreate Respects Casts?

how come? the name is unique

Activity icon

Replied to Does FirstOrCreate Respects Casts?

@snapey I moved the slug to a second argument now it's working fine. With other, more complicated casts, it won't be much help.

Activity icon

Started a new Conversation Does FirstOrCreate Respects Casts?

I have a tag model with the following:

$table->string('name')->unique();
$table->string('slug')->unique();

I am using firstOrCreate():

$name = "test tag 1";
Tag::firstOrCreate(['name' => $name, 'slug' => $name])

An inbound cast is handling the slug before inserting it. This works fine for the first time only. It seems like it only uses the cast for inserting, not for checking if it exists.

Inserting:

insert into
  "tags" ("name", "slug", "updated_at", "created_at")
values
  (
    'test tag 1',
    'test-tag-1',
  )

Checking:

select
  *
from
  "tags"
where
  (
    "name" = 'test tag 1'
    and "slug" = 'test tag 1'
  )

Is there something I could so it would also use the cast when checking with the firstOrCreate() method?

Sep
04
1 month ago
Activity icon

Replied to Use Slug When Possiable Instead Of ID

I think I have to change my approach here and use ID + slug with a 301 redirect, as suggested.

Thanks @click and @snapey

Activity icon

Replied to Use Slug When Possiable Instead Of ID

@click I don't like my current solution as well to avoid a 1999 slug error. The slug must contain at least one character.

I don't feel comfortable that any slug is valid. I care about SEO a lot even though I can use canonical meta tags still doesn't feel right. Less looking for id + slug solution.

My main problem is to make Laravel detect when the slug is updated and use it instead of the ID. When the slug is not set, the post is only accessible to the creator.

Activity icon

Started a new Conversation Use Slug When Possiable Instead Of ID

Let's say users can create posts on my website and only later down the road after the post is created the slug column will be set until that use the post ID to retrieve/edit/show.. posts but when the slug is set use the slug.

route('posts.edit', $post) // slug is not set /posts/1/edit
route('posts.edit', $post) // slug is set /posts/slug/edit

I added resolveRouteBinding() to my post model removed $this->getRouteKeyName() and replaced it with (is_numeric($value) ? 'id' : 'slug') so it can retrieve posts by id if the value is numeric otherwise it will assume it is a slug.

public function resolveRouteBinding($value, $field = null)
{
    return $this->where($field ?? (is_numeric($value) ? 'id' : 'slug'), $value)->first();
}

How would I make Laravel use the slug when it is finally set? Better approach?

Aug
20
2 months ago
Activity icon

Started a new Conversation Find Lowest File Size In A Directory With Laravel?

I need to find the smallest file size from a directory. What is the best way to do it with Laravel and to keep the code as minimal as possible?

I am using this code, but I am sure there is a better and more efficient way.

$files = Storage::files("videos");

$files = Arr::where($files, function ($value, $key) {
    return Str::contains($value, 'string..') && Str::endsWith($value ,'.mp4');
}); // keep only certain files from videos directory in the files array

foreach ($files as $key => $file)
{
    $files[$key] = ['file' => $file, 'size' => Storage::size($file)]; 
}

$min = collect($files)->min('size'); // 1000000

// find file by size...