VortixDev

Experience

330

0 Best Reply Awards

  • Member Since 3 Months Ago
  • 0 Lessons Completed
  • 0 Favorites

3rd May, 2017

VortixDev started a new conversation Displaying Table Data • 1 month ago

Is there an ideal way of pulling all data from a table and displaying it as a HTML table?

1st May, 2017

VortixDev started a new conversation Choose Migration Run Order • 1 month ago

Is there a proper way to change the order in which migrations are run when I "php artisan migrate", other than renaming the migration file? My problem seems to be that when I run the command, it attempts to create a table which has a foreign key that is part of a table which hasn't been created yet, and so I am told that "key column doesn't exist in table". Is there a better way of solving this problem, or must I get the table from which there is a foreign key to be created first?

VortixDev started a new conversation Route Model Binding With Request Object • 1 month ago

How do I take a "Request" object as a parameter to a controller method as well as the model object that's sent due to the binding. Instead of looking at something like this:

"public function method(Model $model)", I'd like to be able to do something like this: "public function method(Request $request, Model $model)". The reason I don't just use "public function method(Request $request)" and get the information required to find the database entry from the request is because I'd also like to use "public function method2(Model $model)" for other methods.

20th March, 2017

VortixDev started a new conversation How To Interlink Table Insertions • 3 months ago

When an entry is inserted in one table (let's call it "table 1"), I want an entry to be inserted into another table as well (let's call it "table 2") (I actually want to have data inserted into one of three potential tables depending on certain information, which is why it's not all under one table). From what I understand, the best way to do this is to create an observer to listen for the "creating/created" events and insert a row into "table 2" when that event occurs. I'm hoping there's an easy way to ensure that if the insertion I control for "table 2" fails, I can prevent the entry to "table 1" which is occuring under the "creating" event from being created as well. Is there an ideal way to do this?

19th March, 2017

VortixDev left a reply on How To Change Insertion Procedures Of A Model • 3 months ago

Looks perfect, thank you!

VortixDev started a new conversation How To Change Insertion Procedures Of A Model • 3 months ago

When one model inserts a new row into its table, I also want it to call upon another model to insert a new row into its table. Let me explain:

I have created three types of accounts, and each of these has a relationship with a central "BaseUser" model. This is necessary as certain information such as email address should be unique through all the accounts, so that a user of account type 1 cannot have the same email address as account type 2. This is made easier by the central "base table". Additionally is the reason of identifying the account type of the user, which is important for operations like password resets.

This means that when a user registers for account type 1, I also want the BaseUser model to create a new entry in its table. I have defined the relationship between this central model and all of the individual account type models, but I'm not sure if there is a simple way to define behavior for the insertion of data other than overriding save and firstOrCreate, and any other methods that may deal with the insertion of data.

26th February, 2017

VortixDev left a reply on Auth::guard('guard')->guest() - Trying To Get Property Of Non-object • 3 months ago

Also, removing the condition and using the following:

{{ gettype(Auth::guard('radius')) }} {{ gettype(Auth::guard('radius')->guest()) ? "True" : "False" }}

Gives me "object" and "True" as results.

VortixDev left a reply on Auth::guard('guard')->guest() - Trying To Get Property Of Non-object • 3 months ago

Unfortunately it seems that Auth::check() only checks for one guard, rather than for both my guard and the in-built web guard.

The following check exists within the layout file:

@if (Auth::guard('web')->guest() and Auth::guard('radius')->guest())

That produces an error when I visit the login page: "Trying to get property of non-object", even though {{ gettype(Auth::guard('radius')) }} and {{ gettype(Auth::guard('radius')->guest()) }} confirm that Auth::guard produces an object and the guest method can be applied to that to produce a boolean. Removing the Auth::guard('radius') check and leaving in the Auth::guard('web') check makes the issue go away.

When, however, I visit the home page, the error doesn't show, even with both conditions in. The main difference between the two pages is the middleware used - "auth" is used by the home controller, whereas "guest" is used by the login page. The home controller uses "auth:web,radius" so that it can redirect any users who aren't logged in with my custom guard as well as the in-built session guard. The login controller uses "guest" alone, redirecting anyone who is logged in using "web" away from the login pages. This means that my "radius" guard is not redirected away. I am wanting to modify the "guest" middleware to make it do so, and this would circumvent my problem, however I don't want to move on until I understand and fix the issue.

To test, I changed the login page to use the "auth" middleware with the parameters I specified for the home controller to use. When I did this, I could use both conditions previously stated without receiving the error.

VortixDev started a new conversation Auth::Guard - Trying To Get Property Of Non-object • 3 months ago

I use Auth::guard('guard')->guest() in the layout of my page to determine whether or not to show the "Login" and "Register" buttons or not - this 'guard' is the guard I have created for a second type of user my system uses. When I'm on a page which uses a controller that utilises the "auth" middleware with parameters "web,guard" then the page loads correctly, but when I visit a page which uses a controller that utilises the "guest" middleware with no parameters then the page doesn't load correctly and gives the error "Trying to get property of non-object". When I (on the same page) have the result of guest() and the result's type printed I get that it is a false boolean (as expected). When I print the type of Auth::guard('guard'), I get that it is an object. I'd appreciate any help understanding this.

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.