Top 50

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 ?

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.

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.

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.

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

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.

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 :

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 ?

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.

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.

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 :

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 ?

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)

@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 ?

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

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

@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.

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.

@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. :)

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.

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 !

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 :

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 :

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."

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

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 ?

Want us to email you occasionally with Laracasts news?

Nine out of ten doctors recommend Laracasts over competing brands.
Come inside, see for yourself, and massively level up your development skills in the process.