pmall

pmall

Bioinformatics engineer at Lyon, France

Member Since 5 Years Ago

Lyon, France

Experience Points
550,695
Total
Experience

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.

Level 50
550,695 XP
Jun
06
4 months ago
Activity icon

Started a new conversation Developper Loneliness

Jan
16
2 years ago
Activity icon

Replied to 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.

Activity icon

Replied to 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.

Activity icon

Replied to 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.

Jan
09
2 years ago
Activity icon

Replied to 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"',
]);
Activity icon

Replied to 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

Activity icon

Replied to Dynamic Content For Download (Content-Disposition The Laravel Way...)

But what is the bug when you do this?

Activity icon

Replied to Dynamic Content For Download (Content-Disposition The Laravel Way...)

it didn't work

Be more specific please :)

Activity icon

Replied to 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.

Activity icon

Replied to Fill A Form By Entering Primary Key

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

Activity icon

Replied to 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.

Activity icon

Replied to Using Var As Relationship Name

No idea. Why do you use a variable attribute?

Activity icon

Replied to Digital Ocean - Traffic

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

Activity icon

Replied to Using Var As Relationship Name

please show the code

Jan
06
2 years ago
Activity icon

Replied to 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.

Activity icon

Replied to Routing Problem

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

Activity icon

Replied to 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.

Activity icon

Replied to 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.

Activity icon

Replied to 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.

Activity icon

Replied to 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.

Activity icon

Replied to How To Use Eloquent In A Validation Rule

The exists rule?

Jan
05
2 years ago
Activity icon

Replied to 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.

Jan
04
2 years ago
Activity icon

Replied to Check If Model Exists For Use In Custom Method

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

$reach = new Reach($campaign);
Activity icon

Replied to 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.

Activity icon

Replied to 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.

Activity icon

Replied to 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.

Activity icon

Replied to 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
Activity icon

Replied to 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.

Activity icon

Replied to 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)]);
}
Activity icon

Replied to 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

Activity icon

Replied to 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.

Activity icon

Replied to 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.

Activity icon

Replied to 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.

Jan
03
2 years ago
Activity icon

Replied to Service Provider And Db Query

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

Activity icon

Replied to 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.

Activity icon

Replied to 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.

Activity icon

Replied to 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.

Activity icon

Replied to 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?

Activity icon

Replied to 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);
Dec
23
2 years ago
Activity icon

Replied to 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.

Dec
16
2 years ago
Activity icon

Replied to 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.

Dec
15
2 years ago
Activity icon

Replied to 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).

Dec
12
2 years ago
Activity icon

Replied to 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/...

Activity icon

Replied to Problem With Blade And @extends

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

Activity icon

Replied to 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.

Activity icon

Replied to 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!

Activity icon

Replied to 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.'.

Dec
09
2 years ago
Activity icon

Replied to Controller Or Model Method

Why not having a relationship between Contry and Hollyday?

Dec
08
2 years ago
Activity icon

Replied to Get Accessor "virtual" Field From View

in view there is not

?

Just do $model->name.

Dec
07
2 years ago
Activity icon

Replied to 5.2 Best Practice For Scopes That Use A Relationship?

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