Romain

Romain

Member Since 7 Years Ago

Experience Points
72,660
Total
Experience

2,340 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
1120
Lessons
Completed
Best Reply Awards
6
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 15
72,660 XP
Oct
22
1 day ago
Activity icon

Replied to Title From Relationship

@bugsysha sorry for the delayed reply. Your solution does not work for me. I want to show a relation field as the title of a resource being edited.

I've looked through the code and I don't think it's possible at the moment.

Thanks for your answer thou

Oct
13
1 week ago
Activity icon

Started a new Conversation Title From Relationship

Hey there,

I have a simple Comment resource in Nova. Of course it BelongTo a Post. When editing, I want the title of the post to be the title of the resource.

By that I mean that when I go edit a comment, I want to see the name of the post at the top: Comment Details: Post name

At the moment, if I add post to the $title property of my resource, I see the whole Post object. But I can't find a way to get the post->title.

Is there a way to do that?

Thanks

Sep
30
3 weeks ago
Activity icon

Replied to Little Regex Confusion

Yep @snapey I ended up with the preg_match_all way

preg_match_all('/(.+?) (\[.+?\]) (\(.+?\))/mi', "The Text I Want [Group One] (Some More)", $matches)
=> 1
>>> $matches
=> [
     [
       "The Text I Want [Group One] (Some More)",
     ],
     [
       "The Text I Want",
     ],
     [
       "[Group One]",
     ],
     [
       "(Some More)",
     ],
   ]

So I guess you get the best answer, thou I will give a try to the Str helper too, forgot that we had that.

Thanks

Activity icon

Replied to Little Regex Confusion

@snapey The rule says "get any characters before the space square bracket", or at least that how I understand it

Activity icon

Replied to Little Regex Confusion

hey @marianomoreyra, thanks for your reply, that sounded interesting however now it returns an array with 2 empty entries:

[
     "",
     "",
   ]

I was using that site (regex101) to test my regex and on the site it matches my string. Im afraid that site only does matches but not captures.

Sep
29
3 weeks ago
Activity icon

Started a new Conversation Little Regex Confusion

Hey,

I thought I had a simple regex split thingy going on, but somehow it's not doing what I want. So basically I have this:

preg_split('/.+?(?= \[)/', "The Text I Want [Group One] (Some more)")

I want it to split the string into:

[
     "The Text I Want",
     " [Group One] (Some more)",
   ]

but instead I get:

[
     "",
     " [Group One] (Some more)",
   ]

Would you know why? Thanks

Sep
24
4 weeks ago
Activity icon

Replied to OnDelete('cascade') Means...

thanks, I feel better now :D

Activity icon

Started a new Conversation OnDelete('cascade') Means...

hey

very quick and easy one but I'm confused with the docs. When I write:

$table->foreignId('submitted_by')->references('id')->on('users')->onDelete('cascade');

I hope that means: When the user with that ID is deleted, then delete this record. Am I right or is it the other way around?

Sep
21
1 month ago
Activity icon

Replied to Hiding Element After X Seconds With Alpine

Thanks @sergiu17 that worked perfectly. It's used to hide a session flash message.

Activity icon

Started a new Conversation Hiding Element After X Seconds With Alpine

Hi,

I think it's all in the title :D. I can't find a way to hide a flash message after 3 seconds with Alpine. What I have so far:

                <div x-data="{ show: true }" x-show="show">
                    <div>
                        {{ session('status') }}
                    </div>
                </div>
                <script>
                    setTimeout(() => show = false, 3000);
                </script>

Any idea? Thanks

Sep
13
1 month ago
Activity icon

Replied to Can I Have A Field With A Relation Through Another Relation?

Well I managed to do what I wanted with your suggestion: In nova:

public function fields(Request $request)
    {
        return [
            ID::make(__('ID'), 'id')->sortable(),
            BelongsTo::make('Season', 'name', Season::class),
            Text::make('Show', function ()
            {
                return $this->show->name; << No need for season anymore
            }),
            HasOne::make('Show')
        ];
    }

and in the Models\Episode

public function show()
    {
        return $this->hasOneThrough(Show::class, Season::class, 'id', 'id', 'season_id', 'show_id');
    }

I just needed to invert the IDs in the hasOneThrough to make it work.

Activity icon

Started a new Conversation Create Multiple Entities

Hey,

upon saving a Show's Season, I want to enter the number of Episode in the Season (say 10) and I want the 10 Episode entities to be created. Can I achieve that with Nova?

I achieved it in the regular part of the site by doing:

 $season->episodes()->createMany(
            Collection::times($request->input('number_of_episodes'), function ($number) {
                return ['number' => $number];
            })
        );

Which works exactly as I want, but how to do it with Nova?

Thanks

Activity icon

Replied to Can I Have A Field With A Relation Through Another Relation?

Sure, but then in Nova, what do I use? HasMany?

Activity icon

Started a new Conversation Can I Have A Field With A Relation Through Another Relation?

Hey there,

quite simple I think, is there a simple way to have access to a relationship through another one?

I have Show <-> Season <-> Episode

on each episode I want to show the Season and the Show name. For now I figured how to display it by doing:

public function fields(Request $request)
    {
        return [
            ID::make(__('ID'), 'id')->sortable(),
            BelongsTo::make('Season'),
            Text::make('Show', function ()
            {
                return $this->season->show->name;
            }),
            
        ];
    }

It works fine, but I don't get a link to the show, I would have to write it myself. Is there a way to have a link between episode and show without adding show_id on each episode?

thanks

Sep
11
1 month ago
Activity icon

Replied to Relationship Between Distant Entities

OK I see, thanks for your input

Activity icon

Replied to Relationship Between Distant Entities

But going through Season to get the Show, doesn't that add another SQL request?

Activity icon

Replied to Relationship Between Distant Entities

Hey,

thank for your reply @automica, I understand this, what I'm wondering is; is it better/easier to have {{ $episode->show->name }}? But having this means having the show_id on the episode table. Is that ok, or too repetitive, not normalized?

Activity icon

Started a new Conversation Relationship Between Distant Entities

Hey guys,

say I have 3 models. Show, Season, Episode.

I want to represent that in the Db, but I'm hitting a wall. If I do it in a "lean" way, the relationship between a Show and an Episode has to go through a Season (Show <--> Season <--> Episode), but how about I add "show_id" on the Episode table and have a show() method that returns the Show?

Is that too much work? Is that against "best practices"? How would you guys go about it?

thanks

Aug
28
1 month ago
Activity icon

Replied to Where Is The List Of Episodes?

Thanks guys, that's what I wanted. Sorry I can only mark one as best answer :D

Activity icon

Started a new Conversation Where Is The List Of Episodes?

Hey,

sorry didn't know where to ask this one. There used to be a list of episode ordered by added date. Where has that gone? I found the "What's new" link under the user icon, it's great, but it's only for the last week. I would want to see all episodes in case I don't come to the site for more than a week and I can see what I missed.

Thanks

Aug
14
2 months ago
Activity icon

Replied to Job Sent To Queue Behave Differently With Eloquent

That was it! I stopped and restarted Horizon, then it was processed successfully. I should have know as one of the job failed and telling me that a specific line expected a numeric value, yet when I checked the file, there was no code on that line. I should have though of a cache issue.

Thanks @talinon

Aug
13
2 months ago
Activity icon

Started a new Conversation Job Sent To Queue Behave Differently With Eloquent

Hi,

I have a very simple job that searches the active users in DB and triggers an action. When I don't queue the job the Eloquent query is respected and only the active users are fetched and triggers, however when I send the job to the queue (by adding ShouldQueue) then all users are triggered. I am using Horizon to process the queue and I can clearly see user tags being passed when they are set to inactive.

Could you think of any reason why that would be?


class TrackUsers implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        // This loads all users instead of just the active ones.
        // If I remove implements ShouldQueue, then it loads only the active users
        $users = User::where('active', true)->get();

        // Scrape data
        $users->each(function($user) {
            TrackSingleUser::dispatch($user);
        });
    }
}
Jul
06
3 months ago
Activity icon

Awarded Best Reply on How Do I Use React Components In Other Views

<Example></Example> will not work. This ReactDOM.render(<Example />, document.getElementById('example')); says: "When there's an element with ID of example, then display the Example component"

So you need <div id="example"></div> if you want the component to show. I tried in users.blade.php and I see the component

Activity icon

Replied to How Do I Use React Components In Other Views

<Example></Example> will not work. This ReactDOM.render(<Example />, document.getElementById('example')); says: "When there's an element with ID of example, then display the Example component"

So you need <div id="example"></div> if you want the component to show. I tried in users.blade.php and I see the component

Jul
05
3 months ago
Activity icon

Replied to How Do I Use React Components In Other Views

ok so I found the reason. There were 2 things.

1: in welcome.blade.php you need <script src="{{ asset('js/app.js') }}"></script> just before the closing body tag. Like that:

    <script src="{{ asset('js/app.js') }}"></script>
 </body>

2: in components/Example.js at line 23, you're trying to render a component called button-users but you haven't imported it, so that can't work. When I change line 23 with:

ReactDOM.render(<Example />, document.getElementById('example'));

I see the component display in the admin panel after having logged in.

If you do these changes, it works as expected

Activity icon

Replied to How Do I Use React Components In Other Views

what do you mean it gives you a 404? You can't access the page after adding that bit of code? It doesn't make sense.

Could you push your whole code on github or somewhere so that we can have a proper look.

Activity icon

Replied to How To Use Same Component For Add And Edit In Vuejs

you could simply check if product exists. in javascript:

product ? product.name : 'default value'

You can use that in the value attributes of the input fields

Activity icon

Replied to HELP, Convert String To Json... ?

with $seccion->information[0]

Activity icon

Replied to HELP, Convert String To Json... ?

You’re working with an array. You will need [0] somewhere. Use dd() to see what is returned

Activity icon

Replied to Strange Relationship - One To Four ?

but then the user decides if it's special. I imagine that you have a submission form, there the user can decide on wether a task is special or not. That is fine, and my suggested structure will still work. All you need is your database to know if a task is special

Activity icon

Replied to How Do I Use React Components In Other Views

add <script src="{{ asset('js/app.js') }}"></script> to your admin layout: 'layouts.adminpanel'

Activity icon

Replied to How Do I Use React Components In Other Views

ok. I'm thinking that you're not loading app.js That's why the component doesn't display. Check how app.js is loaded from the layout used in welcome.blade, and add it to 'layouts.adminpanel'

Should work after that

Activity icon

Replied to How Do I Use React Components In Other Views

Another question: Does: 'layouts.adminpanel' load your Javascript? Is it the file that loads all your scripts?

Activity icon

Replied to How Do I Use React Components In Other Views

what is in: views/admin/users.blade.php ?

Activity icon

Replied to How Do I Use React Components In Other Views

how are you using it? is the other view extending the main layout? By main layout I mean the layout that loads javascript

Activity icon

Replied to Strange Relationship - One To Four ?

Hey, interesting question.

If you can, I would suggest that you re-think your architecture a little. To me it would be simpler to have a table for users and a table for tasks (like you so far) but, the tasks would have a column "special" that is false by default.

In your migration for tasks table: $table->boolean('special', false);

and then for your relationships: In User:

public function tasks() {
  return $this->hasMany(Task::class);
}

public function normalTasks() {
  return $this->tasks->where('special', '=', false);
}

public function spacialTasks() {
  return $this->tasks->where('special', '=', true);
}

Now the trick is then to check how many normal/special task you have on a user when creating a new task. Then deciding wether to create a new one or not. To know how many tasks you have: $user->normalTasks->count() :D

Sorry if the where conditions are off, I did it on top of my head but I'm sure you get the idea