bestmomo

bestmomo

Member Since 4 Years Ago

Toulouse, France

Experience Points 360,020
Experience Level 50

0 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 20
Lessons
Completed
Best Reply Awards 408
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.

09 Mar
5 months ago
08 Mar
5 months ago

bestmomo left a reply on Why Should I Use 'storage:link"?

Your storage is not always placed locally but for example on S3. In this case you need a symbolic link.

bestmomo left a reply on What Css Framework Should I Use?

It's really a matter of personal taste. I sometimes use Bootstrap and sometimes Materialize according to my mood. In any case, you still have to adapt the framework according to the desired visual effect. Depending on the type of project it will guide the choice.

There are good comparatives on the subject like this one.

07 Mar
5 months ago

bestmomo left a reply on Laravel Collectivity Is Not Work 5.8 Version ? The Site Is Off . So How To Do Use It Or Project Develop Without Laravel Collectivity ? Response Skilled Person . About Laravel ..

@towhid For example I have this view for a form :

@extends('layouts.form')

@section('card')

    @component('components.card')

        @slot('title')
            @lang('Ajouter un album')
        @endslot

        <form method="POST" action="{{ route('album.store') }}">
            @csrf

            @include('partials.form-group', [
                'title' => __('Nom'),
                'type' => 'text',
                'name' => 'name',
                'required' => true,
                ])

            @component('components.button')
                @lang('Envoyer')
            @endcomponent

        </form>

    @endcomponent

@endsection

The syntax is clean.

I have a component card, another for the button and a partial pour the input. Here is the partial :

<div class="form-group">
    <label for="{{ $name }}">{{ $title }}</label>
    <input id="{{ $name }}" type="{{ $type }}" class="form-control{{ $errors->has($name) ? ' is-invalid' : '' }}"
           name="{{ $name }}" value="{{ old($name, isset($value) ? $value : '') }}" {{ $required ? 'required' : ''}}>

    @if ($errors->has($name))
        <div class="invalid-feedback">
            {{ $errors->first($name) }}
        </div>
    @endif
</div>

And for eaxample the card component :

<div class="card text-white bg-dark mb-3">
    <h4 class="card-header">
        {{ $title }}
    </h4>
    <div class="card-body">
        {{ $slot }}
    </div>
</div>

bestmomo left a reply on How To Work My Created Sedder Class With My Factory Class

You must call your class :

class DatabaseSeeder extends Seeder

...


public function run()
{
        $this->call(ProductSeeder::class);
}

bestmomo left a reply on Base Url

public_html is your server directory, helper will work if your domain points well on this folder.

bestmomo left a reply on ReferenceError: $ Is Not Defined

So it's the issue, inverse it.

bestmomo left a reply on How To Set Condition Into Button

Yes it's much cleaner with @if and @else.

bestmomo left a reply on How To Work My Created Sedder Class With My Factory Class

Which code did you put in DatabaseSeeder.php ?

bestmomo left a reply on Select Option Not Working

Not sure it's the problem but using clone() has the side-effect of producing elements with duplicate id attributes.

bestmomo left a reply on ReferenceError: $ Is Not Defined

Is your Javascript code included before jQuery loading ?

bestmomo left a reply on Seed Error : Array To String Conversion ...

I think $faker->words generate an array.

bestmomo left a reply on Base Url

Have a look at all helpers ;)

02 Mar
5 months ago

bestmomo left a reply on Can I Show A Card Only For A Specific User Type?

What do you mean with card ?

bestmomo left a reply on Which Version Of Laravel For A Fresh New Project?

In your place I will use version 5.8 without hesitation

bestmomo left a reply on Upgrade To 5.8 :: Class Blade.compiler Does Not Exist

For upgrade the best way is to use a fresh new install and copy files. It may seem longer but finally we save time.

01 Mar
5 months ago

bestmomo left a reply on Laravel Routes

For information I added Controllers command with V0.3

26 Feb
5 months ago

bestmomo left a reply on Helper Issue

With a good hoster you can set the public directory for any sub-domain.

bestmomo left a reply on Migration Do Not Work In Laravel 5.8

Just checked new version 5.8, migrations work nice for me...

bestmomo left a reply on Laravel Routes

For information I added List command with V0.2

24 Feb
5 months ago

bestmomo left a reply on Overwriting Package Code

hi,

I see in config file that you can choose your generator :

/*
|--------------------------------------------------------------------------
| Captcha generator.
|--------------------------------------------------------------------------
| Must implement GeneratorInterface.
|
*/
'generator' => \Igoshev\Captcha\Captcha\Generator\GeneratorWaves::class,

So you can create your own generator et change config to select it.

21 Feb
6 months ago

bestmomo left a reply on Laravel Eloquent Relationship

If you get Trying to get property 'blogpost' of non-object means that you dont get the user, so route binding is not working. How is your route ?

bestmomo left a reply on Setting Vue Data With Props Object Key, Value

Are you sure the data is passed by parent composant when the child is mounted ?

bestmomo left a reply on Setting Vue Data With Props Object Key, Value

You should get all values with your syntax...

To select a pair key/value you only need an index and use Object.entries to get the element.

20 Feb
6 months ago

bestmomo left a reply on Cleaner Controllers

It might also be interesting to do route model binding to avoid :

$instructor = \App\Instructor::find($id);
18 Feb
6 months ago

bestmomo left a reply on Laravel Routes

Thanks both for answers.

@bobbybouwmann

I am not very good with UX ;)

  • I planned to develop the tool with the generation of declared controllers.
  • For route:list as I use Javascript to generate I can't get the PHP intendance, I'll see that...
  • Extra templates would be nice ;)

bestmomo left a reply on How To Do This Better

Or simply :

public function imageUrl($region, $bucket, $directory, $file)
{
    return "http://s3.$region.amazonaws.com/$bucket/$directory/$file";
}

bestmomo started a new conversation Laravel Routes

Hello the forum !

I made a little tool to facilitate the writing of the route file for Laravel. It's still in alpha version.

Hope it'll help...

06 Dec
8 months ago

bestmomo left a reply on Administration

Thank you fort interesting answers but my initial question is on code organisation :)

bestmomo left a reply on Auth::user(); Authentication In Core Php

I made something with Laravel 5.2 to use it with code PHP :

require getcwd() . '/../../../../bootstrap/autoload.php'; // Adapt to your path
$app = require_once getcwd() . '/../../../../bootstrap/app.php';
$kernel = $app->make('Illuminate\Contracts\Http\Kernel');
$response = $kernel->handle(
  $request = Illuminate\Http\Request::capture()
);
$id = $app['encrypter']->decrypt($_COOKIE[$app['config']['session.cookie']]);
$app['session']->driver()->setId($id);
$app['session']->driver()->start();

Then you have Laravel in $app and use $app['auth'] I dont know if it still works with 5.7 version.

bestmomo left a reply on UPGRADE TO LARAVEL 5.7 FROM 5.4

For a clean upgrade install Laravel 5.7 and copy all files. Seems longer but you'll spend less time with bugs tracking ;)

05 Dec
8 months ago

bestmomo left a reply on Using Auth::user(); In Core Php

I made something with Laravel 5.2 to get Laravel app from core PHP :

require getcwd() . '/../../../../bootstrap/autoload.php';
$app = require_once getcwd() . '/../../../../bootstrap/app.php';
$kernel = $app->make('Illuminate\Contracts\Http\Kernel');
$response = $kernel->handle(
  $request = Illuminate\Http\Request::capture()
);
$id = $app['encrypter']->decrypt($_COOKIE[$app['config']['session.cookie']]);
$app['session']->driver()->setId($id);
$app['session']->driver()->start();

Dont know if it works with recent Laravel version but it's a way. You can use $app['auth'] for example.

bestmomo left a reply on Is This Good Approach To Have Own Service Provider?

There is no rule, make as you feel. Code organisation is a story of personal covenant unless the development is done by several people, so they have to agree...

bestmomo started a new conversation Administration

I have explored the available packages to facilitate the construction of an administration: Voyager, LaraAdmin, Backpack, Boilerplate (not Nova which is a paid solution and I code only for fun) and others ... But I can not satisfy myself and I ended almost systematically to create something in my own way ...

But whether it is a package or the personal code we end up with a transplant not necessarily well digested. I like the isolation of treatments because it makes things clearer. At the code level it's easy but when we reason more globally it becomes problematic.

So I thought after all why not completely distinguish frontend and backend with two separate installations of Laravel (or other)? The advantage of the package-specific separation is preserved without the inconvenience of code complexity and mandatory entanglements. It is also easy to reuse the code by enriching it with each project by providing optional features for example.

I think that I will adopt this approach for my next project but I would like to have your opinion on the subject ...

29 Sep
10 months ago

bestmomo left a reply on Array Combine Totals

Not sure to understand your question but array_merge is always working.

bestmomo left a reply on How To Pass Additional Parameters To Resource Class?

@alihoushyaripour

I made a test, you can add an attribute to your model and after send it to your resource. It works.

I made a simple UserResource and :

$user = User::find(1);
$user->test = 'ok';
$resource = new UserResource($user);
dd($resource);

I get that for the resource :

#attributes: array:12 [▼
      "id" => 1
      "name" => "Adam"

      ...

      "test" => "ok"
    ]

bestmomo left a reply on Is Bootstrap-multiselect Plugin Is Compatible With Bootstrap 4.1 ?

Maybe you can use this PR to make it work with Bootstrap 4.

bestmomo left a reply on Want To Access A Particular Array Element.

Could you show dd($data['Documents']) ?

bestmomo left a reply on Database Design / One To Many

  1. I would create a One To One relation between Image and Product (Image has one Product with foreign key on Product).

  2. I dont really understand, you load relation only if you use productImages().

bestmomo left a reply on SetLocale

Usually setLocale is set in a middleware.

bestmomo left a reply on How To Pass Additional Parameters To Resource Class?

Why not just add this to gift ?

$gift->from = 'PlaceController';

bestmomo left a reply on Route For Different User Types

Just send 2 parameters and update your middleware code. Look at documentation.

Something like that :

'middleware'=>['auth', 'Role:1,2']]

...

public function handle($request, Closure $next, $role1, $role2)
{
    if (!Auth::check()) {
        return redirect('/login');
    }

    if ($request->user()->role != $role1 && $request->user()->role != $role2) {
        return abort(404);
    }

    return $next($request);
}
28 Sep
10 months ago

bestmomo left a reply on Append To And Modify Users Collection In Controller Before Pass It To View

@lostdreamer_nl

I think now it's perfect ;)

My first line was to get a simpler collection, not sure it's a good idea...

27 Sep
10 months ago

bestmomo left a reply on Append To And Modify Users Collection In Controller Before Pass It To View

Hello,

With your solution you send 3 queries to database, not really optimized. Maybe this kind of code is better :

$all = collect(User::all()->toArray());

$users = $all->where('competition1', 'yes')->map(function($item, $key) {
    $item['location'] = 'foo';
    return $item;
})->concat($all->where('competition2', 'yes')->map(function($item, $key) {
    $item['location'] = 'bar';
    return $item;
})->concat($all->where('competition3', 'yes')->map(function($item, $key) {
    $item['location'] = 'some';
    return $item;
})));

dd($users);
24 Sep
10 months ago

bestmomo left a reply on Query With Count And GroupBy

If you use Eloquent just do that :

$regios = App\Regio::withCount('inscricoes')->get();

bestmomo left a reply on Difference Between !== & !=

From manual :

$a !== $b Not identical TRUE if $a is not equal to $b, or they are not of the same type.