Full Stack Developer at Chill Pills


Member Since 3 Years Ago

Experience Points 25,445
Lessons Completed 283
Best Reply Awards 1
Best Answer
  • 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


    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement


    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.

13 Mar
9 months ago

dib258 started a new conversation Deauth Or Logout User From Server

Hi there,

I recently developped a small app that do a realtime chat with every user that create an accounts. For that I use Laravel Notifiations, Events and Pusher.

I was wondering something. If at some point a user is not behaving correctly and I have an admin account. Is it possible to ban this user ?

To ban this user this would be something like :

  • delete his account (or not)
  • delete all is message (that can be done by cascading if we delete it's user account)
  • auto-log him out of hist session (that one I don't know if it's possible)
  • if the previous not possible, maybe stop broadcasting events to him ( for this one too I have not clue if it is possible, because for the notifications I use the ->toOthers() method does a spectacular job but I don't know if there is a way to kick a user from a public/private channel)

I thought of something, if I ban someone, that create an events that only him will catch (each one will get it but only the one with the right user id, and that would make an post axios request to log him out). But I don't know if this is not a good thing, because other people could try to spoof such an event and could deauth all the person on the chat ?

Thanks in advance for your help !

12 Jan
11 months ago

dib258 started a new conversation Vue Component Does Propagate Created Data But Not Update/delete

Hi all !

I have the following structure of components :

School -> MapBox -> StudentMap School -> Institute -> Student

School : is just a wrapper (master component)

Institute : Is a CRUD for the institute from the database and has Student's children

Student : is a CRUD for the student

MapBox : Create a OpenStreetMap

StudentMap : Is there to construct the layer with informations with leaflet

I retrieve from the database Institutes which have Students

I know I should need to use Vuex store to have a perfect and clean share of the datas but I had only one week to develop the project and I don't master Vuex still.

The Student component is responsible to edit/delete itself, Institute is responsible to create student, and edit/delete itself. The School, receive the Institutes via laravel json which bind it in the View at the loading.

Whenever an Institute or Student is created/update/deleted, I added event that emits from child to parent to update the data (which is the opposite of what Vue allow but in this usecase I need to let the master component (School) be up-to-date to propagate to the other branch MapBox -> StudentMap.

I have a watcher for the institute / student in the StudentMap and it is triggered when I add new Institute / Student. But when I update / delete, Nothing happen.

I followed of course the good practice to be sure that Vue can catch the modification, like Vue.delete() and Vue.set() or arr.splice() I found thoses informations here (https://fr.vuejs.org/2016/02/06/common-gotchas/)

But Nothing is happening. I don't understand why the Vue propagate the informations when it's created. But not update / delete.

The code is too bit to be put here, but if the description is not clear enough, I created a gist with it all. (https://gist.github.com/dib258/467417e362e5cf6cdecfb839fb53de9e)

Thanks in advance for you help

27 Dec
11 months ago

dib258 left a reply on Execute A Program Outside Of Homestead

Cool that you are coming back ! :D

Thank you for the provision.sh that's what I was looking ! :p

Everything what's Homestead made of.

19 Dec
1 year ago

dib258 left a reply on Execute A Program Outside Of Homestead

Hi @bobbybouwmann,

Long time since I got a good advice from you ! :D

When I decided to relaunch the project on Linux at first I just thought : I'm on Linux, so I'll directly install the server on the machine but then I asked if Homestead was not easier to install and configure everything out of the box (I know, I got addicted to the out of the box :'( ).

Everything would have been perfect if I didn't needed to run this command outside of the virtualization. I even found almost a way to do it but didn't tried it yet.

It's a LaravelCollective package to make SSH command in Laravel (https://laravelcollective.com/docs/5.0/ssh).

So as for you answer I should install a local server and serve my project in local.

Is there some easy way to have all the configuration that is inside the Homestead box ?

Or do I need to install Nginx + PHP + MariaDB + Composer + yarn/npm ?

Thanks in advance ! :)

16 Dec
1 year ago

dib258 left a reply on Error On Dedicated Query String After Homestead Update (PHP 7.2 Ask For Countable Implementation)

It appears that updating Laravel from 5.2 to 5.4 did the trick and fixed the error !

dib258 started a new conversation Execute A Program Outside Of Homestead

Hi there,

I'm currently developing a personal tool with Laravel. Just a local project.

At first, I created it on Windows, using some Wamp to run everything. At some point in the code I am running an exec method to run a program.

Since of now, I am on Ubuntu and I installed Homestead. First the command is not working anymore (since it's not Windows anymore) but also if I do an exec the application would run on the instance of Ubuntu where Homestead exist.

Is it possible to force run application in my computer and not in Homestead ?

I know this is a weird question and probably I should not use Homestead then but I wanted to use it to configure everything out of the box.

Thanks in advance for you help !

dib258 started a new conversation Error Dedicated Query String After Homestead Update (PHP 7.2 Ask For Countable Implementation)


I followed the tutorial on Laracasts to make a dedicated query string filter for Eloquent. (https://laracasts.com/series/eloquent-techniques/episodes/4)

Everything was working perfectly, since I upgraded Homestead to a new version (especially a new version of PHP 7.2).

The version of the Laravel framework I did use is 5.2. I'm planning to upgrade it to the latest 5.5 but here I think the error is more of a change in PHP.

So the error is coming from this line :

$movies = Movie::with(['group', 'genres', 'actors', 'directors'])->filters($filters)->simplePaginate(18);

And the error I get is the following :

ErrorException in Builder.php line 1185:

count(): Parameter must be an array or an object that implements Countable

in Builder.php line 1185

at HandleExceptions->handleError('2', 'count(): Parameter must be an array or an object that implements Countable', '/home/vagrant/server/MovieTheater/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php', '1185', array('scope' => array(object(Movie), 'scopeFilters'), 'parameters' => array(object(Builder), object(MovieFilters)), 'query' => object(Builder)))
at count(null) in Builder.php line 1185
at Builder->callScope(array(object(Movie), 'scopeFilters'), array(object(Builder), object(MovieFilters))) in Builder.php line 1419
at Builder->__call('filters', array(object(MovieFilters))) in MovieController.php line 36
at MovieController->index(object(MovieFilters), object(Request))
at call_user_func_array(array(object(MovieController), 'index'), array(object(MovieFilters), object(Request))) in Controller.php line 80
at Controller->callAction('index', array(object(MovieFilters), object(Request))) in ControllerDispatcher.php line 146
at ControllerDispatcher->call(object(MovieController), object(Route), 'index') in ControllerDispatcher.php line 94

I have my filter class here :


namespace App;

class MovieFilters extends QueryFilter {

    public function actor($actor)
        return $this->getRelationManyToMany('actor')
                    ->select('movies.*', 'actors.name')
                    ->where('actors.name', $actor);

    public function director($director)
        return $this->getRelationManyToMany('director')
                    ->select('movies.*', 'directors.name')
                    ->where('directors.name', $director);

    public function genre($genre)
        return $this->getRelationManyToMany('genre')
                    ->select('movies.*', 'genres.name')
                    ->where('genres.name', $genre);

    public function year($year)
        return $this->builder->where('year', '=', $year);

    public function title($title)
        return $this->builder->where('title', 'like', '%'.$title.'%');

    public function getRelationManyToMany($otherTable)
        $singular = $otherTable;
        $plural = str_plural($otherTable);
        return $this->builder->join($singular.'_movie', 'movies.id', '=', $singular.'_movie.movie_id')
            ->join($plural, $otherTable.'_movie.'.$singular.'_id', '=', $plural.'.id');

And the QueryFilter class from Jeffrey that I inherit :

<?php namespace App;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;

abstract class QueryFilter
    protected $request;

    protected $builder;

     * QueryFilter constructor.
     * @param Request $request
    public function __construct(Request $request)
        $this->request = $request;

    public function apply(Builder $builder)
        $this->builder = $builder;

        foreach ($this->filters() as $name => $value) {
            if (method_exists($this, $name) && array_filter([$value])) {
                call_user_func_array([$this, $name], array_filter([$value]));
        return $this->builder;

    public function filters()
        return $this->request->all();

So If I understand well the error is that It appears we are trying to iterate on an empty array, or a null object and it ask to implement the Countable interface on my filter class or the QueryFilter one.

But in the code I don't see some iteration and I tried to implement the interface Countable on MovieFilters but I don't know what to put in the count method which is abstract and so required to redefine.

Could someone help me finding what tweaks to make this work again. Since this code was working perfectly before the Homestead update.

Thanks in advance for your help !

12 Oct
1 year ago

dib258 started a new conversation How To Access Nested Array In Vuex Where Each Array Is A Component

In my Vuex Store, I have a planning state where it describe the planning of a week.

planning : [
            name : 'monday',
            meetings : [
                    name : 'morning',
                    value : ''
                }, {
                    name : 'noon',
                    value : ''
                }, {
                    name : 'evening',
                    value : ''
            name : 'tuesday',
            meetings : [
                    name : 'morning',
                    value : ''
                }, {
                    name : 'noon',
                    value : ''
                }, {
                    name : 'evening',
                    value : ''



I have specific component that are also nested like this


Here are the codes for those components


    <div class="week columns is-desktop is-vcentered">
        <PlanningDay v-for="(day, index) in planning" :key="index" :day="day"></PlanningDay>

    import PlanningDay from './PlanningDay';
    import { mapState } from 'vuex';

    export default {
        computed : mapState(['planning']),
        components : {


    <div class="day column">
        <p class="name has-text-centered" v-text="day.name"></p>

        <PlanningMeeting v-for="(meeting, index) in day.meetings" :key="index" :meeting="meeting"></PlanningMeeting>

    import PlanningMeeting from './PlanningMeeting';

    export default {
        props : ['day'],
        components : {


    <div class="meeting">
        <p class="has-text-centered" v-text="meeting.name"></p>
        <input type="text" v-model="meeting.value">      

For each day I have PlanningDay.vue which retrieve the day from his props and then render it. Is it the Vuex kind of way to do ? Since every retrieve/modification are normally passing through a commit or a getter from the Vuex Store.

What would be the best way to render nested arrays in Vuex Store ? Since right here I just have to modify values from the period of the meeting. I won't change the value of the day nor the time (morning, ...).

Since everything must come from the backend I think I must be in the Vuex Store (coming with a axios request to the API).

Also since I retrieve values in the props coming from the parent component, how could I be able to bind meeting.value which came from the props from PlanningDay which comme from PlanningWeek ?

Since modifications are made with commit to change the state this would look like something like this :

    export default {
        props : ['meeting'],
        computed : {
            meetingList : {
                get() {
                    return this.$store.state.planning[planningId].meetings[meetingId];
                set(value) {
                    this.$store.commit('updateValue', ...planningId, meetingId, ... value);

So I would bind the v-model with meetingList computed properties or something like this but how to manage to retrieve the planningId and meetingId, I mean in the proper way. Since the point of Vuex is to not put event, and props everywhere and extract this data layer.

So am I doing something wrong ? and how is the best way to manage nested arrays in Vuex to pass data to nested component ?

Thanks in advance for you answer !

14 Aug
1 year ago

dib258 left a reply on Create User + Authentication Automatic

Yep but in that case security is not important, it's like an information session, you come to get data/informations and then leave.

The website create a user during you process through your journey to know who you are and discuss with you but in the end if we loose you or someone would retrieve your cookie it's not important since you don't give personnal datas.

dib258 started a new conversation Create User + Authentication Automatic


I would like to let a user come to my website and be connected and treated as a user without having to register and/or connect. The way I wanted to recognize him is from a cookie created the first time the user connect.

If the user lose is cookie, he will be reasigned a new one and a new user account.

I think it is possible to assign to a new user a cookie, and create user regarding the value we assign to this user (in the cookie) to recognize him later.

I would try to design something, but this feel so much like a known features that I'm asking before if this is not something done like all the time and there's a special name for that.

The fact that I want to have a user created / loggued for this user is that User represent a good way to handle the customer in like a chat or something and to broadcast message you need in Laravel to have a user, but if the project is not meant for the user to register/login. What is the solution here.

Hope I was clear enough for you to understant.

Ask me question if no.

Thanks in advance for you answers !

23 May
1 year ago

dib258 started a new conversation Gate Does Not Work


I am trying to implement Policies in my project and I have a custom method askFriend that I want to add to my UserRelationPolicy.

So I implemented in my UserRelationPolicy the askFriend method but when trying to call it from the [email protected] I asked myself how to call it from this method.

Something like $this->authorize('askFriend', $friend); but it was not working, kind of ignoring it at all. So I searched further in the documentation and found that I could bind with a Gate method the specific method in the UserRelationPolicy to a resource name like this :

Gate::resource('userrelation', 'UserRelationPolicy', [
    'userrelation.askfriendrelation' => 'askFriendRelation'

You can find the representation here : https://laravel.com/docs/5.4/authorization#writing-gates

When I try to execute this code I get the following error :

Call to undefined method Illuminate\Auth\Access\Gate::resource()

And nothing more. The Resource method doesn't seem to exist at all. After many search, trying to include every Gate in the header. Trying to call it staticly or with an instance. Nothing work and the method is nowhere near to be found...

Is it something forgotten ? How can I call a custom method from a controller in a policy class ?

Thanks in advance for your help because I searched this for hours...

22 May
1 year ago

dib258 started a new conversation Policies With A Certain Type Of Routes


I have the following route in web.php :

    Route::resource('user.place', 'PlaceController', [
        'except' => ['index']

And I'm creating a policies. For example : [email protected]

    public function edit(User $user, Place $place)
        return $user->id === $place->user->id;

And the edit method in the PlaceController :

 public function edit(User $user, Place $place)
        $this->authorize('edit', $place);

        return view('place.edit', compact('user', 'place'));

By default, the authorize or can method is going to take the authenticated user to make the check and pass it to the [email protected].

With the route I created the url is something like this /user/x/place/y.

So if I go to user/1/place/1 and I own place 1 and I'm connected as user 1. No problem I can access the edit for this place.

But If I go to user/2/place/1 and I own place 1 and I'm connected as user 1. The current authorization doesn't care about the user in the url. Only the authenticated user.

So my main question is : Is my method of routes wrong since the authorization process will never check it ? Or can I in some way pass the user from the url and test also if he is the authenticated user. (Otherwise I can end up with someone typing /user/100/place/1 but the security is applied to the place but the user in the url is wrong)

Because at first I was doing the test like this in the [email protected] :

    if (
            ($place->user_id == $user->id)
            (Auth::user()->id == $user->id)
        ) {
        return view('place.edit', compact('user', 'place'));
        } else {
            return ['message' => 'Don\'t try to be someone else'];

I was testing if the authenticated user own the place and if the authenticated user is the user from the url.

Thanks in advance for you help.

09 May
1 year ago

dib258 left a reply on Broadcast PresenceChannel Between Two People

@JeffreyWay In the documentation for Laravel Echo, It's not clear of the way to join a room. Still in the documentation, chat.${roomId}, what is roomId ? A simple variable that could be in the data or props ?

@bobbybouwmann (It seems you always have the right solution ! :p)

dib258 left a reply on Hacked Again :(

Try to change hosting and maybe use Laravel Forge service, which configure your server and patch security update automatically !

dib258 left a reply on Broadcast PresenceChannel Between Two People

No one is using the broadcasted events ? :p

dib258 left a reply on Is It Possible To Make A Form Loads Without Without Database In Laravels?

A form to loads what then if there's no database ?

If you mean generate a form then you have the package from LaravelCollective Html & Forms

08 May
1 year ago

dib258 started a new conversation Broadcast PresenceChannel Between Two People

Hi there,

I'm trying to make Broadcasted event work for a case where two user share a conversation (like a chat) where only the two of the can access and get notified when a new message comes.

I think, after reading the documentation that the presence channel is the best option (private is for one people and the server and channel is for something plublic without checking ?)

So in my routes/channels.php I have something like this :

Broadcast::channel('conversation.{conversation}', function ($user, Conversation $conversation) {
    if ($user->id === $conversation->user1_id || $user->id === $conversation->user2_id) {
        return $user;
    return null;

In the client side a Component I have :

    .here((users) => {
        this.usersInRoom = users;
    .joining((user) => {
    .leaving((user) => {
        this.usersInRoom = this.usersInRoom.filter(u => u != user);
    .listen('MessagePosted', (e) => {
            id :e.message.id,
            user_id :e.message.user_id,
            conversation_id :e.message.conversation_id,
            user :e.user,
            text :e.message.text,
            created_at :e.message.created_at,
            updated_at :e.message.updated_at,

And the class that emit the even MessagePosted :

    public function broadcastOn()
        return new PresenceChannel('conversation.'.$this->message->conversation_id);

So I now that previously I used a PresenceChannel without any checking, so if two people where in there conversation they would get notification from everyone. not the right thing.

In the server side, I have the 'conversation.{conversation}' that was mentioned in the documentation to make a separated channel. But I also saw something like 'conversation.*'.

And on the client side I have join('conversation.${conversation.id}') but here I am not sure at all I just know that I have in the props (props : ['user', 'friend', 'conversation']) a conversation which is an object with the id of the conversation.

So When, when everyone was on the same channel with no restriction everything was working perfectly and now, I think I have an error which make the whole thing not work.

I have an 500 server side error when I load a client conversation :

ReflectionException in Broadcaster.php line 170:
Class Conversation does not exist

Thanks in advance if you can help me configure all of this !

26 Apr
1 year ago

dib258 started a new conversation Contain A User To A Specific Part Of The Platform Until He Does Tasks

Hi there,

The project I'm currently woking on need to contain a user until he does certain task.

So he would only be able to acces like 2-3 pages and not all the platform.

I think I would add a boolean to the user which state that he has or has not yet done the tasks.

I think the restrain needs to come from the route file.

Like a route group or something like this but I can't figure out how to apply a check to a number of route to check if the user has done the tasks.

Thansk in advance for you answer,

15 Mar
1 year ago

dib258 started a new conversation Design Relations For A Model That As Two Foreign Key Pointing To The Same Class

Hi there,

If I have a database looking like this :

Database design

How to design relations for a model that as two foreign key pointing to the same class ?

Since, for this example, the UserRelation model would have two foreign key pointing to User.

I cannt do something like :

public function users() {
    return $this->hasMany(App\User::class);

Could you point me in the right direction please ?

Thanks in advance !

23 Aug
2 years ago

dib258 left a reply on Access Relationship Or Property In A Variable

Yes, it works alright. I found the error. I was trying to attach on a belongsTo relation. Which was returing the weirdest error.


22 Aug
2 years ago

dib258 started a new conversation Access Relationship Or Property In A Variable


I'm trying to create a new element with a model but the properties or the relationships are in some variables. Someone told me to use { $property } to let eloquent know to look in the variables.

$property = 'name';
$model->{$property} = $value;

This seems to work when trying to access a property well but not when trying to access a relationship.


Is there another way to access a relationship when the name is in a variable or I don't use the correct syntax ?

Thanks in advance.

13 Jun
2 years ago

dib258 left a reply on Forge Is Not Creating My Ssh Key In The Server

@ejdelmonico Ok, So I juste removed the one I added in the DigitalOcean>Security>SSH Key

I also rebooted the server (from forge this time) but it's still not working.

Is there something else missing ?

dib258 started a new conversation Forge Is Not Creating My Ssh Key In The Server


I am configuring a new server (DigitalOcean with Forge) and like each time, I have errors when trying to configure the SSH connection.

I made each step like it's need to be done :

  • Generated my id_rsa and id_rsa.pub
  • I copy / paste it (with pbcopy) to forge ssh and DigitalOcean ssh
  • Added the id_rsa to my keychain with ssh-add

When I connet to the server with the DigitalOcean tools, I see that my ssh key are not on the server. So I tried to reboot the server but nothing happend still nothing in the authorized_keys nor a new file with id_rsa.pub in the /home/forge/.ssh

So I keep getting this message over and over again

ssh [email protected]
Permission denied (publickey).

Does anymone could know If I forgot a step or if there is a way to make this works ?

Thanks in advance

28 Apr
2 years ago

dib258 left a reply on Npm Install Stack Size Exceeded

@Arrilot, I actually managed to fix this error. The thing is in windows the url size is limited to 260 characters. So to bypass is to rename the folder which is chared with homestead. Mine was called 'LaravelProjects' I renamed it to 'l'.

If you User name is long maybe you could try to put the folder somewhere more close to the C:\

The problem happening with the npm is that when installing depedencies they goes real real deep and creating a lot of subfolder. That's why the stack size is exceeded.

Good Luck ;)

18 Apr
2 years ago

dib258 left a reply on Call RestFull Method And Add Another Param

@Prez, The thing is I have a place controller that has multiple media.

To fix my problem when calling the MediaController@store method and passing along the id of the place by a hidden input was successfull.

Now I want to do the same with the destroy method. But when I create the form with the method => DELETE, then I can't pass along any data via hidden input. I get this error

MethodNotAllowedHttpException in RouteCollection.php line 219:

I think I need to get something working by passing this place id by url.

Something like this :

POST       /place/{id_place}/media/store
DELETE  /place/{id_place}/media/{id_media}

That's what I was saying "how to chain controller withing controllers". The fact is that when I call the MediaController It's always via a PlaceController's method.

dib258 started a new conversation Parse Uploading Picture From Form


I'm working on a backoffice for an application that runs with Parse.com for it's database. So I'm using it in Laravel to make the modifications. I'm kind of stuck when trying to upload a picture from a forms into the parse database since apparently storing files in parse is ok.

public function store(Request $request) {
    $id = $request->input('redirect_id');
    try {
        $file = null;
        if ($request->hasFile('pictures')) {
            $upload = $request->file('pictures');
            $file = ParseFile::createFromFile($upload->getPath().'/'.$upload->getClientOriginalName(), $upload->getClientOriginalName(), $upload->getClientMimeType());

        $media = new ParseObject('Media');

        $media->set('place_id', $id);
        $media->set('media_data', $file);

    } catch(ParseException $ex) {

    return redirect()->route('place.edit', $id);

And I'm getting this error :

file_get_contents(/tmp/1920x1200-3.png): failed to open stream: No such file or directory

And the createFromFile method from Parse :

public static function createFromFile($path, $name, $mimeType = null)
    $contents = file_get_contents($path, 'rb');
    return static::createFromData($contents, $name, $mimeType);

So, I don't know why the file_get_contents can't reach the picture that has been uploaded maybe he can't access from the temp directory but it's weird.

Maybe I need to use the createFromData method

public static function createFromData($contents, $name, $mimeType = null)
    $file = new self();
    $file->name = $name;
    $file->mimeType = $mimeType;
    $file->data = $contents;

    return $file;

But what should I do to retrieve the content of the picture uploaded since the file_get_contents is not working ? Should I move the picture somewhere else so it to be accessible ?

Thanks in advance for your answer !

dib258 left a reply on Call RestFull Method And Add Another Param

@Prez, yeah I don't know I thought it would be better to put the id in the url to pass the data along the controllers but now I'm thinking that you're right and I don't need to try to mess with the RestFull way the url are working. But I'm still a bit blurry how to chain controllers within controllers maybe that's why I wanted to do it by passing by the url. :)

15 Apr
2 years ago

dib258 left a reply on Call RestFull Method And Add Another Param

@Prez, Okai that would have been my last solution but it'll do it. Thanks :)

dib258 left a reply on Call RestFull Method And Add Another Param

@Prez, I know that it doesn't need any id to store since it's note created yet.

The id I want to pass along is the Id of the Place to make the redirection after store the new media.

dib258 left a reply on Call RestFull Method And Add Another Param

You're right I forgot the {!! !!}, It's changed

The first solution you said gave me an url of : http://getly-backoffice.app/media?id=3

The second solution generate this url : http://getly-backoffice.app/media?3

Both doesn't work.

Shouldn't I make something special in the route ?

Right now I went back to this :

Route::resource('media', 'MediaController', [
    'except' => [

dib258 left a reply on Call RestFull Method And Add Another Param

Thanks for you quick answer DPJack. When I try your solution (I thing that now I neeed to remove the id from the routes file then)

I changed in my form like you said and I get an error like this

Missing argument 2 for App\Http\Controllers\MediaController::store()

Since my MediaController@store is like this :

public function store(Request $request, $id) {

    return redirect()->route('place.edit', $id);

dib258 started a new conversation Call RestFull Method And Add Another Param

Hi there, Right now, I have a normal controller (index, create, store, update ,....) called PlaceController and when I edit one item It show in the template also other subelement that depend from the item (like media, etc..)

The thing is, I want at the end of for example calling MediaController@store because they added new media I want to redirect to the PlaceController@edit so I need to pass along the id of it.

Right now I had

Route::resource('place', 'PlaceController');
Route::resource('media/{id}', 'MediaController', [
    'except' => [

But when I try to create the form in the PlaceController@edit I tried something like this {{ Form::open(['method' => 'POST', 'route' => ['media.id.store', $id]]) }}

I get an error like this : Route [media.id.store] not defined.

What should I do ?

Is it ok to try to pass along an id (since to store a new element no id is needed) in a resource controller or should I make a simple route to call the specific method like this :

Route::post('media/{id}', 'MediaController@store');

Thank you in advance for you answer

08 Feb
2 years ago

dib258 left a reply on Error With Vagrant

Are you sure that you synced dir with homestead is 'Code' and your project dir is project ?

dib258 started a new conversation Npm Install Stack Size Exceeded


I was creating a website with Laravel on my mac. I recently tried to retrieve it on a windows computer and I installed everything with homestead etc...

But now when I try to run npm install I get this error message :

vagrant@homestead:~/LaravelProjects/leadercom$ npm install --no-bin-links
npm WARN deprecated lodash@2.4.2: [email protected]<3.0.0 is no longer maintained. Upgrade to [email protected]^4.0.0
npm WARN deprecated npmconf@2.1.2: this package has been reintegrated into npm and is now out of date   with respect to npm
npm WARN deprecated lodash@1.0.2: [email protected]<3.0.0 is no longer maintained. Upgrade to [email protected]^4.0.0
npm ERR! Linux 3.19.0-25-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "--no-bin-links"
npm ERR! node v5.5.0
npm ERR! npm  v3.7.1

npm ERR! Maximum call stack size exceeded

I don't get why get this stack sie exceeded since I never got this error and everything is working perfectly on my mac and on my server.

My package.json is :

    "private": true,
    "devDependencies": {
        "gulp": "^3.8.8"
    "dependencies": {
        "laravel-elixir": "*",
        "bootstrap-sass": "^3.3.5"

Thanks in advance if you can help me with my problem, it's maybe windows related.

23 Dec
2 years ago

dib258 started a new conversation Install HTML Minifying, Where To Use The Gulp New Task


I want to install a plugin to minify the html online to have a faster response from the server. I found a solution but I'm not sure it's the best way nor how to implement it.


They say I need to create a new gulp task and the call this command : gulp compress

It'll compress the template created by Laravel but when do I need to run this command.

  • On my server when logged in with SSH ?
  • Or to add it in the deploy script in forge ?
  • Or simply in local and everything will be in the git repository and automatically send on the server ?

The last one seems useless since there's a .gitignore in the ./storage/framework/views/ so no files goes on the repository.

Thanks in advance for your help !

dib258 left a reply on Adding Expiration Date On Static Files (Nginx Configuration)

I finally found where the code must go. Instead of putting the code in /etc/nginx/nginx.conf, you must go to /etc/nginx/sites-available/{ your server file } and add it in the server {}.

I also optimized the code to be more large (including fonts for example).

location ~* \.(ico|css|js|gif|jpeg|jpg|png|woff|ttf|otf|svg|woff2|eot)$ {
        expires 30d;
        add_header Pragma public;
        add_header Cache-Control "public";
22 Dec
2 years ago

dib258 started a new conversation Adding Expiration Date On Static Files (Nginx Configuration)


I'm trying to optimize a client's website on laravel and using Google's page speed, it keeps saying that I send no expiration date on the static files I send to the user.

So I tried to search how can I do that I found that I need to add some code in the nginx.conf. (https://www.howtoforge.com/make-browsers-cache-static-files-on-nginx)

So I went to the nginx.conf on my server and tried to add the following code

location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
   expires 4w;

They say I can add it inside the http{} or the server{}. Since there's no server{} in my nginx.conf file I tried to add it in the http one.

I also found a way to check if the file has really an expiration date with this command

curl -I http://www.mysite.com/picture.jpg

and I get this response

HTTP/1.1 200 OK Server: nginx/1.8.0 Date: Tue, 22 Dec 2015 21:00:49 GMT Content-Type: image/png Content-Length: 7595 Last-Modified: Tue, 22 Dec 2015 18:07:53 GMT Connection: keep-alive ETag: "56799179-1dab" Accept-Ranges: bytes

So no expiration date on the file. So I tried to change the place and created a server {}. (I also restarted each time nginx with sudo service nginx reload off course !) And I get the same answer no expiraction date on the file.

Am I doing something wrong, using the wrong code or adding the code at the wrong place, to tell nginx that I want him to send an expiration date !

Thanks in advance !

dib258 left a reply on Implode Of Content From DB And Implode Them With Array_map

Thanks for your answer, but I wanted to do it with the implode method.

For now I already used a foreach like this :

            <?php $first = true; ?>
            @foreach($article->tags()->where('type', 'person')->get() as $person)
                @if ($first)
                    {{ $person->name }}
                    <?php $first = false; ?>
                    , {{ $person->name }}

21 Dec
2 years ago

dib258 started a new conversation Implode Of Content From DB And Implode Them With Array_map

Hi there,

I wanted to make implode my tag names coming from my db.

So First, I retrieve them : $articles = $article->tags()->where('type', 'person')->get()

After that, I wanted to use an array_map function to implode only the name of the tag. Because normally when we have the result of the code above, we do a foreach and have each iteration an object on which we can get the name like this :

@foreach($articles as $article)
    {{ $article->name }}

So it seems that the get() method return an array of object.

$a = array_map(function ($obj) {
    return $obj['name'];
}, $article->tags()->where('type', 'person')->get());   

implode(', ', $a);

But now there's an error the array_map says that what I gives is not an array and when I do a var_dump it's an object of Eloquent/Collection.

So I try to get an array out of it and add ->toArray() after. But now I dont have an array of object but an array of arrays of content.

And changing the function of the array_map by :

function ($obj) {
    return $obj['name'];

Doesn't help at all.

Is there a simple way to do what I want ? I wanted to avoid doing a for an checking the first element to add the ', ' but I encounter many more troubles..

Thanks in advance

03 Dec
3 years ago

dib258 left a reply on Adding Picture When Register

Damn you're right ! I forgot to add the image in this array...

Thanks!!! :)

dib258 started a new conversation Adding Picture When Register


So, I'd like that, when a user register, he can add a profile picture. I made the new input in the template and I filled the create method in AuthController.php :

protected function create(array $data) {
    $fileName = 'null';
    if (Input::file('image')->isValid()) {
        $destinationPath = public_path('uploads/files');
        $extension = Input::file('image')->getClientOriginalExtension();
        $fileName = uniqid().'.'.$extension;

        Input::file('image')->move($destinationPath, $fileName);

    return User::create([
        'name' => $data['name'],
        'email' => $data['email'],
        'image' =>  $fileName,
        'password' => bcrypt($data['password']),

When I try it the image upload correctly to the right folder but when I use thinker to see if the picture name is in the DB. There's nothing :

$user = App\User::OrderBy('id', 'desc')->first(); => App\User {#689 id: 5, name: "John Doe", email: "john.doe@gmail.com", image: "", created_at: "2015-12-03 11:48:12", updated_at: "2015-12-03 11:48:12", }

I tried many times and I can't understand why the picture name wont insert in the DB. I tried to replace the $fileName in the return user creation by "test" but nothing also. Is it the right method called when the registration is called ?

I would think so since the new update in laravel RegistersUsers.php page's postRegister method call the create method I used :

public function postRegister(Request $request)
    $validator = $this->validator($request->all());

    if ($validator->fails()) {
            $request, $validator


    return redirect($this->redirectPath());

Thanks in advance for your help !

25 Sep
3 years ago

dib258 left a reply on Git / Elixir: Avoiding Merge Conflicts (using Forge)

We opted to run the gulp command on the server and removed /public/build from the git.

Now everything works fine ! No more merge conflict at each commit !

21 Sep
3 years ago

dib258 started a new conversation Difficulties Starting Homestead Under Ubuntu

When typing "homestead up" from the command line, I'm getting a strange error:

"The specified host network collides with a non-hostonly network! This will cause your specified IP to be inaccessible. Please change the IP or name of your host only network so that it no longer matches that of a bridged or non-hostonly network."

Any idea on how to solve this?

15 Sep
3 years ago

dib258 started a new conversation Converting Illuminate\Http\Request To Array

I'm making in use of a library that expects to receive a native PHP array such as is obtained from the global $_REQUEST.

Unfortunately in this instance, the Illuminate\Http\Request is an object, and seems to have quite a different structure to the native php array. Is there a method to convert that object to the same array that would be obtained via '$_REQUEST' (which doesn't work inside a laravel controller method).

Thanks in advance.

01 Sep
3 years ago

dib258 left a reply on Array_merge() With Eloquent Models

Ok, many thanks!

dib258 started a new conversation Array_merge() With Eloquent Models

Hello, I've been trying to merge arrays containing eloquent model instances, but no success so far.

With the following code:

 $tags = [];
  for ($i = 0; $i < count($articles); ++$i) {
    $ts =  $articles[$i]->tags->all();
        array_merge($tags, $ts);

The $tags array stays empty. The $ts array I'm trying to merge into it contains an array of Tag instances.

Is this normal behaviour?

31 Aug
3 years ago

dib258 started a new conversation Git / Elixir: Avoiding Merge Conflicts (using Forge)

Hello, I am looking for recommandations in a laravel git workflow that would allow us to work avoiding as many merge conflicts as possible using files auto-generated by elixir.

For example, we had the following conflicts after trying to pull a remote branch in the local one: Auto-merging resources/assets/sass/app.scss CONFLICT (content): Merge conflict in resources/assets/sass/app.scss Auto-merging public/css/all.css.map CONFLICT (content): Merge conflict in public/css/all.css.map Auto-merging public/css/all.css CONFLICT (content): Merge conflict in public/css/all.css Auto-merging public/build/rev-manifest.json CONFLICT (content): Merge conflict in public/build/rev-manifest.json Auto-merging public/build/css/all.css.map CONFLICT (content): Merge conflict in public/build/css/all.css.map CONFLICT (rename/rename): Rename "public/build/css/all-045bb8d591.css"->"public/build/css/all-78c0b8ef05.css" in branch "HEAD" rename "public/build/css/all-045bb8d591.css"->"public/build/css/all-cff4a29f15.css" in "homecontroller"

In all of these conflicts, only the app.scss one and the public/build/css/all-cff4a29f15.css (needed by forge) are unavoidable.

Should all other public files be under .gitignore?

26 Aug
3 years ago

dib258 started a new conversation Sass Parse Bower Plugin

Hi there,

I just installed bower to be able to simply add plugins.

I created a .bowerrc with this config in it :

{ "directory" : "resources/assets/bower" }

I downloaded via bower the bootstrap-sass-official an tried to parse it in Elixir like this :

    mix.sass(['app.scss', '../bower/bootstrap-sass/assets/stylesheets/_bootstrap.scss'], 'public/css/all.css');

When I run gulp there is no error and when I look in the all.css there's only the code from my app.scss. And the path to the boostrap is correct.

I opened the _bootstrap.scss to see what's inside :

// Core variables and mixins
@import "bootstrap/variables";
@import "bootstrap/mixins";

// Reset and dependencies
@import "bootstrap/normalize";
@import "bootstrap/print";
@import "bootstrap/glyphicons";

// Core CSS
@import "bootstrap/scaffolding";
@import "bootstrap/type";
@import "bootstrap/code";
@import "bootstrap/grid";
@import "bootstrap/tables";
@import "bootstrap/forms";

It seems that when elixir take the file and execute it, it doesn't take in account the _bootstrap.scss path and so can't import any file.

I found an hacks temporarily, I had in my app.scss :

@import '../bower/bootstrap-sass/assets/stylesheets/_bootstrap.scss';

and modify my elirix mix :

mix.sass(['app.scss'], 'public/css/all.css');

And now it works.

Is it obliged to do this way or did I miss an argument somewhere ?

Thanks in advance

dib258 left a reply on Forge Deployement Using Bower

not the bower.js but the bower_components ?

Isn't that the point of using a package manager ? When you use composer to install a new plugin, the plugin doesn't go on github and is redownloaded on the production machine. Is it different for bower plugins ?