xbtdev

u/xbtdev


r/Spanish•

What's the longest stream of vowel sounds you've encountered in your learning so far?

I recently came across this sentence, which made me realise we don't get that so much in English:

Va a ir a un museo.

18

r/laravel•

SOLVED: Tiny typo from typing out code manually, looked like a way bigger problem than it actually was. I'll leave this here to see if anyone can see the typo and note what a dummy I've been...

...actually, in the interest in helping newbies: I typed __constructor instead of __construct


I had been trying to achieve this with a completely seperate middleware class, but recently decided since my middleware is tiny, to just use a closure (pasted below). However, I can't seem to get access to this $site data in any of the other controller functions.

class ManageController extends Controller
{
    private $site = 6;

    public function __constructor()
52

r/laravel•

Where can I find detailed information on this 'with' function? This seems to be basically the extent of coverage in Laravel's documentation (under redirects):

return redirect('dashboard')->with('status', 'Profile updated!');

https://laravel.com/docs/5.3/responses#redirecting-with-flashed-session-data

It's obviously a really inconvenient function name for Googling.

Edit: Nevermind, I found the source:

/**
 * Flash a piece of data to the session.
 *
 * @param  string|array  $key
 * @param  mixed  $value
 * @return \Illuminate\Http\RedirectResponse
 */
public function with($key, $value = null)
{
    $key = is_array($key) ? $key : [$key =
713

r/PHP•

This has no doubt already been thought of and programmed by someone else, but after more than an hour of searching for it with no luck, I finally just decided to write it myself:

public static function property_path_exists($object, $property_path)
{
	$path_components = explode('->', $property_path);
	
	if (count($path_components) == 1) {
		return property_exists($object, $property_path);
	} else {
		return (
			property_exists($object, $path_components[0]) && 
			static::property_path_exists(
				$object->{array_shift($path_components)}, 
				implode('->', $path_components)
			)
		);
	}
}

Usage:

if (prope
120


r/Spanish•

I hadn't thought about this before, but with hindsight it may be obvious - when I changed Windows to Spanish, some keyboard shortcuts that I was so used to also changed.

For example, for decades I've always been able to hit Ctrl-S to save some text in notepad. But now that my OS is in Spanish, I have to get used to hitting Ctrl-G for guardar.

It's not a dealbreaker, I'll keep my OS in Spanish and get used to the differing shortcuts, but I must say - these shortcuts have been a lot harder to get used to than just reading different menus, etc.

73

r/laravel•

In Laravel 5.2 we can change the default field that gets used by the auth functions for login/register, by adding this line to AuthController.php:

protected $username = 'username';

Laravel 5.3 however, does away with AuthController in favour of two separate ones:

  • LoginController.php
  • RegisterController.php

So, in order to switch the default login field from 'email' to 'username', do we have to add that line of code to both of these?

Anyone done a min-tutorial on this issue yet?

Edit After digging around Laravel's source, I found this in vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php:

/**
 * Get the login username to be used 
68



r/laravel•

I don't have a github account, but I see the latest 5.3 is still using the incorrect form of 'Log In'.

  • Log In <-- this is a verb (e.g. Please log in / Log in here )
  • Login <-- this is a noun or an adjective. (e.g. Enter your login. / What's your login ID?)

The menu item should use the verb. The header on the login page should use the verb. The button on the login page should use the verb. The fact that this error is in a popular framework is especially annoying because it means thousands upon thousands of new sites will probably also have the error (just like reddit does on one of its login buttons).

2018

r/webdev•

I have an API (built in Laravel 5.2) which I'm trying to adhere as much as possible to standard verbs. As such, the following allows a user to get one of his messages, or retrieve all of his messages:

Route::get('messages/{id}', 'APIController@get_message');
Route::get('messages', 'APIController@get_messages');

My problem is, there are other types of users, which have admin privileges. This means they will not only be able to see ANY individual message, but 'all' should mean for EVERY user:

Route::group(['middleware' => 'App\Http\Middleware\AdminOnly:api'], function(
{
    Route::get('messages/{id}', 'APIController@get_message');
    Route::get('messages', 'APIC
723