bestmomo

bestmomo

Toulouse, France

Member Since 4 Years Ago

Experience Points 356,620
Experience
Level
Lessons Completed 19
Lessons
Completed
Best Reply Awards 405
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

29 Sep
1 month 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.

27 Sep
1 month 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
1 month 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.

23 Sep
1 month ago

bestmomo left a reply on Property [id] Does Not Exist On This Collection Instance!!!!

Let's show some code. Maybe you try to get attribute on collection without iterate...

bestmomo started a new conversation Photos Gallery

For information I put on Github an example of a photo gallery.

It serves as the basis for a series of French turoriels on my blog.

17 Sep
1 month ago

bestmomo left a reply on Load Js Dependecy In My Bootstrap.js

Luckily there is something else that bootstrap and jquery :)

bestmomo started a new conversation Bug In Mix ?

Say in my resources/js/app.js I add a require for sweetalert :

window._ = require('lodash');
window.Popper = require('popper.js').default;
window.swal = require('sweetalert2');

So I launch npm run dev. My sweetalert is not loaded. But now if i change a bit :

window._ = require('lodash');
window.swal = require('sweetalert2');
window.Popper = require('popper.js').default;

It works !

I have tried with other libraries with same result...

Any idea ?

Thanks

11 Sep
2 months ago

bestmomo left a reply on Delete File From Dir With Unlink

@tykus

Even the core doesn't use the FileSystem ^^

In UpCommand Console command :

@unlink(storage_path('framework/down'));

bestmomo left a reply on Eloquent Get Insert Id

When you create a record with Eloquent you get the id in the model :

$flight = App\Flight::create(['name' => 'Flight 10']);
$id = $flight->id;

bestmomo left a reply on Route With Names Issue

When you use get you get a collection of elements and you must iterate, if you have only one element use first or firstOrFail.

10 Sep
2 months ago

bestmomo left a reply on Helper Function

Happy it works now ;)

bestmomo left a reply on [SOLVED]Requests Not Validating Contact Form

I suppose you use flash package, I never used it but did you installed it correctely ?

bestmomo left a reply on [SOLVED]Requests Not Validating Contact Form

Looks like I got the good answer above ^^

bestmomo left a reply on Helper Function

Do you use some contact variable on this page ?

bestmomo left a reply on Requests Not Validating Contact Form

Remove this line in ContactFormRequest :

use Illuminate\Foundation\Http\FormRequest;
//use App\Http\Controllers\ContactFormRequest;
use App\Mail\ContactEmail;
use Flash;

bestmomo left a reply on Helper Function

With this code you cant get Undefined variable contact...

bestmomo left a reply on Helper Function

Do you really use this code :

<?php

if (!function_exists ('sections')) {
    function sections()
    {
        return \App\Models\Section::all();
    }
}

if (!function_exists ('site_data')) {
    function site_data()
    {
        return \App\Models\SiteData::first();
    }
}

if (!function_exists ('social')) {
    function social()
    {
        return \App\Models\Social::first();
    }
}

if (!function_exists ('contact')) {
    function contact()
    {
        return \App\Models\Contact::first();
    }
}

bestmomo left a reply on Helper Function

Remove these lines :

namespace App\Http;
class helpers
{

It's not a class just a php file with functions

bestmomo left a reply on Helper Function

Dont forget namespaces :

<?php

if (!function_exists ('sections')) {
    function sections()
    {
        return \App\Models\Section::all();
    }
}

if (!function_exists ('site_data')) {
    function site_data()
    {
        return \App\Models\SiteData::first();
    }
}

if (!function_exists ('social')) {
    function social()
    {
        return \App\Models\Social::first();
    }
}

if (!function_exists ('contact')) {
    function contact()
    {
        return \App\Models\Contact::first();
    }
}

bestmomo left a reply on Helper Function

Why not simple like that :

if (!function_exists ('sections')) {
    function sections()
    {
        return \App\Models\Section::all();
    }
}
...

bestmomo left a reply on Helper Function

I have updated my answer.

bestmomo left a reply on How To Access Public Path Image

$output = '
        <td><img height="50" src="' . url("/imageslogo-1.png") . '" alt="Image"/></td>
  '

bestmomo left a reply on Helper Function

The simple way is to create an app/helper.php file for all your helper functions and load it with composer :

"autoload": {
    "classmap": [
        "database/seeds",
        "database/factories"
    ],
    "files": [
        "app/helpers.php"
    ],
    "psr-4": {
        "App\": "app/"
    }
},

In your helper file you set your helper methods, for example :

<?php

if (!function_exists ('currentRoute')) {
    function currentRoute(...$routes)
    {
        foreach ($routes as $route) {
            if (request ()->url () == $route) {
                return ' active';
            }
        }
    }
}

bestmomo left a reply on Helper Function

Why do you extend Controller to make an helper ?

bestmomo left a reply on How To Access Public Path Image

I dont understand how you manage your code. Why dont you use Blade for this ?

08 Sep
2 months ago

bestmomo left a reply on Laravel 5.7 Email Confirmation

Now I've got it ;)

bestmomo left a reply on Laravel 5.7 Email Confirmation

@staudenmeir

Right, I made copy and paste to have link and got &amp; , thanks ;)

07 Sep
2 months ago

bestmomo left a reply on Laravel 5.7 Email Confirmation

Yes I did all that is said in doc : implements MustVerifyEmail in User and 'verify' => true in routes.

bestmomo started a new conversation Laravel 5.7 Email Confirmation

Hello,

Just testing Laravel 5.7 today and set the email confirmation on a fresh installation. I get the email, click on link and only get a 403 page.

Looks like hasValidSignature used by ValidateSignature return false but I dont know why...

Any idea ?

bestmomo left a reply on How To Turn Off Auto Login Users ? In Laravel 5.7

Hello

Override register function that showed you @OriOn in your RegisterController.

30 Aug
2 months ago

bestmomo left a reply on Database Realtionships

Hello,

I think you should have a look at documentation, starting there.

23 Aug
2 months ago

bestmomo left a reply on WithTrashed

Do you use the Illuminate\Database\Eloquent\SoftDeletes trait ?

22 Aug
2 months ago

bestmomo left a reply on Call To A Member Function Where() On Null

There is something not logical...

When you write :

History::find('item_id')

You get only 1 row... what about the where ?

bestmomo left a reply on JSON Column - Find Any Matching Value

You can only do that with raw query as said @36864 . Look at MySQL documentation.

bestmomo left a reply on Image Upload With Original Name In Laravel 5.6

When you say "in database" do you mean in users table ? Because you dont use getClientOriginalName on it...

bestmomo left a reply on Icons & Animations

FontAwesome 5.2 is great and worth upgrading with nice SVG.