pmall

pmall

Member Since 5 Years Ago

Lyon, France

Bioinformatics engineer at Lyon, France

Experience Points 550,195
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 44
Lessons
Completed
Best Reply Awards 608
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.

06 Jun
2 months ago

pmall started a new conversation Developper Loneliness

16 Jan
2 years ago

pmall left a reply on To "Repository Pattern" Or Not?

Usually if you don't have a clear reason for using a pattern, then you don't need it.

Eloquent + scopes are fine for me. If you have complex eloquent construction you want to reuse you can wrap it in a scope.

pmall left a reply on Possible To Have A HasMany As Well As A HasOne Relationship With The Same Model?

It works perfectly. But here you will have the administrator in the regular user list. If it is the intended feature, everything is fine.

pmall left a reply on With A HasMany Relationship, How To Get Only The Parents Without The Children?

I don't understand. Parent::all() return only parent models. If you don't ask eloquent to retrieve relationship it wont.

09 Jan
2 years ago

pmall left a reply on Dynamic Content For Download (Content-Disposition The Laravel Way...)

I'm sure I can reduce it to 1 line or even create a quick shortcut method somewhere.

Third parameter of the response object/helper is an associative array o headers :

$response = response('File contents', 200, [
    'Content-Type' => 'application/json',
    'Content-Disposition' => 'attachment; filename="myfile.txt"',
]);

pmall left a reply on Dynamic Content For Download (Content-Disposition The Laravel Way...)

Object retuned by response() does not expose a headers property.

How to manage headers is explained here https://laravel.com/docs/5.3/responses#creating-responses

pmall left a reply on Dynamic Content For Download (Content-Disposition The Laravel Way...)

But what is the bug when you do this?

pmall left a reply on Dynamic Content For Download (Content-Disposition The Laravel Way...)

it didn't work

Be more specific please :)

pmall left a reply on Dynamic Content For Download (Content-Disposition The Laravel Way...)

Here you're not streaming the file. The whole file is generated and stored in memory as you have a $fileContent variable.

The only way to stream a csv is to use Symfony\Component\HttpFoundation\StreamedResponse with a callback generating the content.

pmall left a reply on Fill A Form By Entering Primary Key

Please be more specific. What have you tried to do?

pmall left a reply on How To Design OO Applications.

With laravel designs patterns are already set up for you. Except if you have a very very specific requirement, anything a web app can require fits in some laravel feature.

pmall left a reply on Using Var As Relationship Name

No idea. Why do you use a variable attribute?

pmall left a reply on Digital Ocean - Traffic

You will always end up paying for the bandwidth of your website if it gets a lot of traffic.

pmall left a reply on Using Var As Relationship Name

please show the code

06 Jan
2 years ago

pmall left a reply on How Delete All "throug" Relations Without Foreach?

You have no choice but to loop over the object. Whats the problem with foreach ?

You can set up observers on your models so when you delete one it cascade through its children.

@SaeedPrez matches collection doesn't have a goals() relationship.

pmall left a reply on Routing Problem

@iGenezys the route of your localhost must be your public folder.

pmall left a reply on How To Use Function In Eloquent Query?

how do I go about querying the model using the 'isLive()' function to filter through results?

This is totally impossible. You cant "pass" php code to sql.

You must generate a proper sql query, probably by using a where clause and a boolean column.

pmall left a reply on Can See Site Via Domain Name But Not Via IP Address

This is perfectly normal your virtual host is configured to respond to requests with your domain name as hostname.

pmall left a reply on How To Register A Service Provicer Dynamically?

There is no way really. You will need at some point to register it.

You can distribute a base application which test if some service providers exists and if any register them.

But if you have a good deployment strategy it is not a problem. Pull new code from you git repo including the service provider registering and running composer intall.

pmall left a reply on How To Register A Service Provicer Dynamically?

The question is why do you want to do this?

There is no magical method, if you want to configure a package you need to write something somewhere at some point.

PS : some guys are trying to solve this problem if I understand correctly http://docs.puli.io/en/latest/ . But it is far away from widespread adoption.

05 Jan
2 years ago

pmall left a reply on More Elegant Way To Handle Properties Of Null Object

Do not hide errors, it is ugly as hell! What if another errors is produced when using avatar->url?

@MikeHopley solution is obviously better. Or you can handle it the regular way : a method hasAvatar() and a conditional.

04 Jan
2 years ago

pmall left a reply on Check If Model Exists For Use In Custom Method

You should delegate the processing of a model to another object.

$reach = new Reach($campaign);

pmall left a reply on Assign Unserialize Laravel Object To JS Array

var branches = {!! json_encode(unserialize($preliminary->branches)) !!};

You were printing an array in a web page, escaping it and assigning it to a js var, so of course javascript syntax error.

You must get your array as json string (hence the json_encode) and not escape it (hence the !!) so you get a valid javascript syntax.

pmall left a reply on How Check If Record Is Exit And Soft Delete

can you please tell me how to do the soft delete

Just read the doc about soft delete. Once you put the traits in your model you just call delete() like your code above.

pmall left a reply on Where I Put My Custom Functions To Be Accessed In View (laravel 5.3)?

You can also set custom blade directives (check the docs) so you can directly write something like @romanic_number($n) in you views.

pmall left a reply on Passing User Id To A Many To Many Relationship

You just have to set up a relationship between User and Place and use it :

@foreach (auth()->user()->places as $places)
//
@endforeach

pmall left a reply on Vuejs: Separate Requests To Separate Routes Vs. Post To An Update Route - What Is Better Design In Your Perspective?

Why not sending a put/patch method (you're obviouly modifying an entity) with the data you want to update? If you change the status just send the new status value.

pmall left a reply on Custom 'exists' Validator For Hashed Ids

You can make custom validation rules. Check the docs.

Also you can use the form request to decode your id :

// in the form request
public function all()
{
    $this->merge(['user_id' => decode($this->user_id)]);
}

pmall left a reply on How Check If Record Is Exit And Soft Delete

$dlesson = Lesson::findOrFail(input::get('id'));

$dlesson->delete();

findOrFail throws a model not found exception if not found

pmall left a reply on Modern Dev Forces Me To JS When I Want To PHP.

Whats so different in making an api or an html app? Returning json instead of html?

But I agree, I don't like all this JS thing. I usually try to put the less possible javascript in my apps, just the minimum required. It ends up in multiple pages with some javascript component into it.

Look at this successful laracast website for example, it is perfectly fine and it is not api/js only.

pmall left a reply on Right Way To Validate Form Input Fields

Create a form request and make an array with 52 rules.

What is strange is not to validate 52 fields, it is to have 52 fields.

pmall left a reply on Validation With Two The Same Rules And Different Error Messages

Create a custom rule for email_verified, then you can assign it a custom message.

03 Jan
2 years ago

pmall left a reply on Service Provider And Db Query

Why do you all want to run queries in a service provider?

pmall left a reply on Delete Event Not Fired

The bug in your first post was that $user->documents() returns a query builder and not a collection. To get the collection of documents you have to use $user->documents.

$user->documents()->delete(); doesn't fire event because it is just running a sql query for deleting those rows in the database. Events are fired when you actually use the delete method of a model.

pmall left a reply on Query From Two Tables With 'Where' Conditions

as I don't have location model

Well you should have one ^^

Also you can change the key of the relationship to use the location column.

Wouldn't it be cleaner if I could query like this

The clean way is to make model when you obviously need a model and to make a relationship when you obviously try to emulate a relationship.

->where('location', $order->location) : this is exactly what is a relationship between order location and user.

pmall left a reply on Query From Two Tables With 'Where' Conditions

This is not a problem with the query but your website design. I don't understand in which way you think doing ($agent->location == $order-location) is different from a relationship and how it would solve your 100 agent problem.

pmall left a reply on Query From Two Tables With 'Where' Conditions

I'm not sure what you want exactly. ($agent->location == $order-location) mean all the agents for a given location so a simple relationship between loaction and agent will do the trick. I don't understand your concerns about having 100 agents?

pmall left a reply on Query From Two Tables With 'Where' Conditions

This is simply chaining relationships :

@foreach ($orders as $order)
@foreach ($order->location->agents as $agent)
<option value="{{ $agent->id }}">{{ $agent->name }}</option>
@endforeach
@endforeach

Order belongs to Location, Location has many User.

Then to scope it to the 3 status :

$orders = Order::with(['location.users' => function ($query) {

    $query->whereStatus(3);

}])->latest()->paginate(10);
23 Dec
2 years ago

pmall left a reply on Is There A Size Limit On Requests?

I had problems when trying to send thousands of post fields at the same time (wried I know but required). The solution I came up with is to serialize them into one field then unserializing them when receptioning it.

Servers can also have limitation for the size of the input, but it can be configured.

16 Dec
2 years ago

pmall left a reply on Should This Code Be In The Controller? (google Charts Back-end)

really shows me how much of Laravel I need to learn

This is not especially a laravel feature. With any language when you think some piece of code doesn't belong at some place, you can always extract it to its own class.

15 Dec
2 years ago

pmall left a reply on How Can I Keep Content Consistent?

Why do you let the user enter the start time? isnt it equal to the previous end time (or now if it is the first).

12 Dec
2 years ago

pmall left a reply on Get Storage Url...

You just have to put a simlink from your public folder to your storage folder.

Example : public/avatars => storage/app/public/avatars. Then store your files in storage/app/public/avatar and access them from http://yourdomain.com/avatars/...

pmall left a reply on Problem With Blade And @extends

You should review your logic, having a conditional layout is really messy.

pmall left a reply on Notifications -- Times Wrong

Same as @Snapey - I got 6 hours ago living in france, @willvincent gets it in the future living in usa, definitively a timezone thing.

pmall left a reply on Code Blocks Not Colored On First Load

For me code almost never get highlighted. At least make the default code block color white, not drakgrey on black!

pmall left a reply on Form Validation: Custom Error Message With Input Value

@philwgreen @thirtythree the only way is to create a custom validation rule with a custom message :

use Illuminate\Validation\Validator as BaseValidator;

class Validator extends BaseValidator
{
    protected function validateUniqueName
    {
        // Return boolean, can make use of parent validator validateUnique method.
    }

    protected function replaceUniqueName($message, $attribute, $rule, $parameters)
    {
        // parent class $data attribute contains all the validated values.
        $name = Arr::get($this->data, $attribute);

        return str_replace([':name'], [$name], $message);
    }
}

And of course you must have a custom error message for unique_name rule containing placeholder to replace : 'unique_name' => ':name has already been registered to another team.'.

09 Dec
2 years ago

pmall left a reply on Controller Or Model Method

Why not having a relationship between Contry and Hollyday?

08 Dec
2 years ago

pmall left a reply on Get Accessor "virtual" Field From View

in view there is not

?

Just do $model->name.

07 Dec
2 years ago

pmall left a reply on 5.2 Best Practice For Scopes That Use A Relationship?

I also readed some 5.0.* version fixed this so update your laravel version.