Connect with the state? Laravel – Stack overflow in Spanish

Good I have personalized the login proposed by the same Laravel, I can enter everything correctly but now I have added a new column to the users table called Estado where if you have a 0 is active and if you have a 1 This is disabled. Then, I tried that at the moment the username and password are connected, you can only enter the system if your state is 0 and if your state is 1, you do not enter, but you enter the system, regardless of the status of deactivation.

-Controller LoginController code:

public function login(Request $request){
        $credentials = $this->validate($request,(
            'Usuario' =>'required|string',
            'Clave' =>'required|string'

        $credenciales = (
            'Usuario' => $credentials('Usuario'),
            'password' => $credentials('Clave')

        if(Auth::attempt($credenciales) && Auth::user()->Estado == 0){
            return redirect('/');
            return back()->withErrors(($this->username()=>'Estas credenciales no concuerdan con nuestros registros'));

J & # 39; adds Auth::user()->Estado == 0 because i have searched in other questions that came as answer but i still do not understand how can i solve this problem?

Where to place complex business logic in a state machine?

I have a state machine that has about 10 states. Whenever I receive a valid event for the current status of the state machine, I will handle this event, which will change the state machine to another state.

The commercial logic involved here is quite complex, I use the model of mediator to delegate this responsibility elsewhere, because I do not want to inject 20 services into my state machine.

However, this basically means that, from state A, I will receive an event, call the mediator reason to indicate the work to be done, which will bring the machine to state B.

I now have the feeling that my state machine is not doing anything, all the logic to decide in which state the state machine must pass is delegated, so that it becomes a little anemic.

Is this the right approach? If not, what are the best practices for managing complex business logic in a state machine?

unit – Easily save and load the complete state of a GameObject in Unity3D?

I'm working on place predefined tilemap rooms in my procedural dungeonsand I would like design the location of objects and monsters in these special rooms as well as.

Currently I "compile" my preconceived room scene in scriptable object, and the map generator loads this tilemap in tilemap "gameplay".

I'm already analyzing the special game objects in the scene (like objects and monsters), and store their transformations and prefabricated roads in the scriptable object.

But this has 2 problems:

  • Have each object and monster in the resource folder would make my executable huge.

    • But that could be solved by doing a "MonsterPrefabDictionary" on a manager like gameobject, and drop each prefab into this list in the editor. The map generator will simply use this dictionary to find the prefab of the object.
  • the bigger problem Is each monster variant would need another prefab (or prefabricated variant). And by variation, I mean also small changes.

    • Do you want a crowd to have only 50% health in the room early? Make a prefab for that?

    • You want a monster to start with a specific buff in this room? Make a prefab for that?

    • Do you want a monster to have a different position from the usual one in this room? Make a prefab for that?

    • As you can see, it weighs badly.

    • But that could be solved by store all MonsterScript data in the object that can be the subject of a script.

    • But that would be bad scale toobecause each new information about a monster should also be added to this serialization process.

is there integrated, automatic, easy for just register the complete state of a GameObject and just load everything with a single line later?

(T / F and explain) An NFA accepts the empty string if and only if its initial state is an end state

(T / F and Explain) An NFA accepts the empty string if and only if its starting state is a final state.

This question concerns automata, NFAs and DFAs. Thank you

Change state from one child to another by obeying SOLID principles

I am a little puzzled about the following example:

public class Driver{
    ICar car;
    public Driver(ICar car){ = car;

    public void Drive(){

    public void ChangeCar(ICar car){ = car;
public class ICar {
    void Drive(Driver owner);
public class ExampleCar : ICar{
    private int fuel;

    public ExampleCar(int fuel){
        this.fuel = fuel;

    public void Drive(Driver owner){
        if(fuel > 0){
            Console.Writeline("driving exampleCar. Fuel: " + fuel);
        owner.ChangeCar(new AnotherCar(200));
public class Main{
    ICar car = new ExampleCar(100);
    Driver mcLaren = new Driver(car);

    for(int i = 0; i < 200; i++){

So, what's going on basically here is
"Drive ExampleCar, if the ExampleCar fuel is empty, switch to AnotherCar"

A kind of "finite state machine sudo" (I do not know if it's even close to a finite state machine, but that's the best interpretation I can understand)

So with that, I try to achieve a change of state based on a condition that only the current state is able to check (ie if the fuel is empty ).

It does not seem logical to move the condition to the driver class and check it, as this would violate the open / close principle (assuming I want to put a new ICar, which has a completely different condition or none at all. condition at all, for example)

but this current implementation seems to violate the principle of dependency reversal, because ICar depends on Driver.

I do not know what to do here, whether or not, this implementation is ok.

I would appreciate your thoughts about it.

unit testing – Decoupling redux reductive tests of the form of the state

Recently, I've been refactoring the form of the state in a fairly important redux application, and I've found that one of the obstacles to accomplishing this task is that testing my Reducers clearly have a lot of "knowledge" about the "shape" of the state tree. .

There are a lot of tests that look like this:

const nextState = reduce(startState, action.doSomething());


So now, when I want to restructure so that the somethingwasdone boolean is stored under have to make similar changes in a potentially large number of tests.

One thing I was wondering is this: is it advisable to dissociate the reducing tests from the form of the state using selectors? So:

const nextState = reduce(startState, action.doSomething());

The advantage of this is that when you change the shape of your state, you only need to change the appropriate selectors to match them, and you do not need to modify your gearbox tests.

A disadvantage is that when a reducer test fails, you do not know a priori if it is because there is a problem with the reducer or a problem with a selector. But this does not seem to be a costly disadvantage compared to benefits.

One thing that makes me think is that I never see this template in Redux tutorials, books, or documentation.

Am I missing something? Are there other disadvantages I have not thought of? Is the problem I mentioned above more serious than I thought?

Any advice or comment would be welcome.

eu – Several stays of three months in a Member State in free circulation

Can I leave for a period of time (say a month) and then have the right to re-enter and stay there another month (or three months if necessary)?

Basically, the answer is Yes. As you may know, this is controlled by Directive 2004/38 / EC

There is not much clarity on this because it is just not applied very regularly. In fact, a citizen of the EU can stay indefinitely in another State subject to very limited conditions. Among these conditions, the host country may impose an obligation on the register of EU citizens. But any penalty for non-registration must be "proportional" to penalties for citizens of a country that do not register. (This is why the United Kingdom does not, strictly speaking, require recording.)

(I guess the exceptions for public safety, public health and public policy are not at stake.)

As a result, there is not much reason to look for people who have not registered and have been here for more than three months. The benefits simply do not justify the costs. In addition, such an enforcement effort would be extremely difficult, as the EU does not stamp the passports of EU citizens. It would not be easy to locate the person and determine the actual length of their stay. On the other hand, someone who had crossing the border from one country to another, theoretically resetting the three-month deadline, may also have difficulty in presenting evidence of this fact.

Consider someone who is informed by the authorities of a country that they have complied with the obligation of registration. Such a person is likely to register or leave. Or maybe the authorities would accept the assertion of the person to be a party and returned, in which case they could impose a later registration deadline. Whatever it is, for both parties, going to court would not be profitable. There is therefore no judicial precedent (to my knowledge) to reach an answer.

A person present in an EU country other than their own for less than three months is not subject to the obligation of registration. Your question could be redrafted as follows:

After a three month stay in an EU country in free circulation, what does it take to reset the three month period?

The answer probably depends on several factors and, more importantly, a specific analysis of each case. Consider someone who moves all his belongings into a country house, lives there and goes away for a month. After the return of the person, it is reasonable to argue that the person has exceeded his right of residence for three months. However, a person traveling in the country with a backpack for three months can reasonably claim that it reinstates the period with an absence of a day or two. In addition, different EU countries will consider this issue differently (remember, the UK does not even require registration), so the answer also depends on the country in question.

The foregoing assumes that the person is autonomous and therefore falls under point 1 (b) of Article 7. If this is the case, the person can not be expelled from the country or be refused entry. If this is not the case, then, then the person can to be expelled from the country. One wonders if they can then be refused later. The linked article makes it clear that the directive is quite clear, but two governments are trying to create such a possibility (see also Poor sleeping conditions do not constitute an abuse of EU rights in relation to free circulation).

If a person who was not self-sufficient repeatedly entered a country and became a nuisance, a ban on "abuse of rights" (Article 35) could be imposed. But a second entry, one month after an initial stay of three months, would have very little chance of reaching that level.

matrices – State space model / description of the ratio of blood and insulin ratio

I am currently trying to solve a state space model for a person's blood glucose ratio and insulin ratio.

The following is presented in the problem:

I (t) = ratio of insulin in the body

S (t) = ratio of blood glucose in the body

The stable baseline state is a fixed level with a level of hypoglycemia = S0 and an insulin level equal to zero.

The following properties are presented for each state variable (I (t), S (t)):


  1. The presence of insulin increases the rapid turnover rate (= reduction in blood content). The higher the content of sugars and insulin, the higher the turnover is. It is assumed that the blood level decreases in proportion to the product of the sugar and insulin content.
  2. If the level of sugar in the blood falls below the stable reference point (S0). Sugar will be processed by the liver in proportion to the sugar deficit.
  3. An increase in blood sugar occurs during the consumption of food. The effect of this is proportional to the time function z (t)


  1. If the blood sugar level exceeds S0, the insulin is released proportionally to the excess sugar.
  2. Insulin itself has a limited duration. Half of the free insulin becomes inactive within 10 to 25 minutes
  3. If the patient is diabetic, an external injection must be made. Suppose that the amount of insulin administered is proportional to a function of w (t), which describes the pattern of injection.

The question is:

Provide a description of the state space with the relationship between blood sugar content (S (t)) and insulin content (I (t)) as state variables .

What I've tried / interpreted: for sugar:

  1. S (t) = -k1 (S (t) -S0)
  2. k3 (S0-S (t)) = S (t)
  3. Z (t) = S (t)

combined: S (t) = -k1 * k2 * I (t) * S0 + k1 * k2 * I (t) * S (t) – k1 * k2 * I (t) * z (t)

For insulin:

  1. k3 (S0-S (t)) = I (t)
  2. k4 (I (t)) = I (t)
  3. w (t) = I (t)

Combined: I (t) = k3 (S0-S (t)) + k4 (I (t) + w (t))

Is the interpretation correct? If so, how can I continue to get the state variables S-t and Y (t)?

usability – How to resolve the ambiguity of the selected state in a segmented control with only two segments?

I'm working on a web application with two similar data grids in one page. The user should be able to switch between these two data grids on the same page.

I've used segmented buttons to navigate between these two grids. But I think that this component visually becomes a seesaw and that the current state of the seesaw becomes ambiguous.

For now, I'm only relying on the color / hue to display the selected state, but I do not know which state to choose.

Is there a better approach to solve this problem?

Segmented buttons surrounded in red
enter the description of the image here

animation – How to activate ENABLE ROOT MOTION on the state machine?

In this question (also posed by me), I had trouble putting animation on my object:

Basically, the position and size of the character have changed.

It should look like this:

enter the description of the image here

But it looked like this:

enter the description of the image here

I managed to solve by activating this option:

enter the description of the image here

Not only by putting directly in the character, but also by using BlendSpace.

But using the state machine, this error is returned:

enter the description of the image here

The transition between the animations is working properly, but this error now occurs in the game:

enter the description of the image here