ravasaurio

ravasaurio

Member Since 2 Years Ago

Experience Points
7,550
Total
Experience

2,450 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
61
Lessons
Completed
Best Reply Awards
1
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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 2
7,550 XP
Jul
16
3 months ago
Activity icon

Replied to How To Use Conditional WHERE In Raw Queries Like In Eloquent

You can use whereRaw method:

$orders = DB::table('orders')
                ->whereRaw('price > IF(state = "TX", ?, 100)', [200])
                ->get();

https://laravel.com/docs/5.8/queries#raw-expressions

Jun
06
4 months ago
Activity icon

Replied to Validation With Required_if And Not_in Not Working

When you don't check a checkbox it wont be present on the request. Try with required_with instead of required_if:

'state' =>  'required_with:tocheck',

As for the not_in rule, it won't be necessary here: you can let the value on your 'Please Select' option as an empty string. Laravel will convert that to null with the ConvertEmptyStringsToNull middleware and since tocheck is checked, it will be present on the request so state is not allowed to be null. But just to clarify,your usage of the not_in rule is wrong. Here's how you use it:

You need to import

use Illuminate\Validation\Rule;

and use it like this:

'tocheck'  => 'sometimes',
 'state' =>  ['required', Rule::notIn(['Please Select', 'foo', 'bar'])],

Finally, I don't think you need the sometimes rule on your tocheck. The sometimes rule is intended to use with other rules. It is used when something is not required to be present, but needs to meet some requirements when it is present. So if you are OK with your tocheck not being on your request (when it is not checked) but you need it to be boolean, or numeric, or whatever when it is checked, then you use sometimes:

'tocheck'  => ['sometimes', Rule::in(['on'])], // It is not required, but if it's present, then it needs to be 'on' otherwise validation will fail

https://laravel.com/docs/5.8/validation#rule-required-with https://laravel.com/docs/5.8/validation#rule-not-in https://laravel.com/docs/5.8/validation#conditionally-adding-rules https://laravel.com/docs/5.8/validation#rule-in

Activity icon

Replied to How To Send Data To Database From A Form Using If Or Similar Conditions:

You can not use required for your artist_name, music_genre_id and sub_music_genre_id because your label type users will not have that data, so those fields have to be nullable. You have radio buttons to choose what kind of user you are creating, so I will assume you have something like this:

<input type="radio" name="type" value="artist"> Artist
<input type="radio" name="type" value="label"> Label

The fields artist_name, music_genre_id and sub_music_genre_id only need to be present when artist is chosen, so you should try with required_if instead:

'artist_name' => ['required_if:type,artist', 'string', 'max:25'],
'music_genre_id' => ['required_if:type,artist', 'string'],
'sub_music_genre_id' => ['required_if:type,artist', 'string'],

https://laravel.com/docs/5.8/validation#rule-required-if

May
31
4 months ago
Activity icon

Replied to How To Design Notification Table For Social Networking Site

https://laravel.com/docs/5.8/notifications#database-notifications

Laravel uses a single table for all of your notifications. You can create this table by executing the php artisan notifications:table command and then php artisan migrate. Then you can use php artisan make:notification YourNotificationClassName to create the notifications you need (post like, friend request etc). Once you have your notifications ready, you can notify your users with $user->notify(new YourNotificationClassName()). This will create a record on the notifications table. Note that the data column on this table will hold an array you can define on the toArray method of every notification. Use this if you need to store something like a friend request text or something.

You can iterate through a user's notifications with:

foreach ($user->notifications as $notification) {
    // do your thing
}

or

foreach ($user->unreadNotifications as $notification) {
    // do your thing
}

You can count them:

$user->notifications->count();
$user->unreadNotifications->count();

And you can mark them as read or delete them.