aschorr

aschorr

Member Since 2 Years Ago

Experience Points
1,180
Total
Experience

3,820 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
7
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 1
1,180 XP
Oct
06
1 week ago
Activity icon

Started a new Conversation Best Way To Host API Routes And Client App On Same Domain

I'm developing a web app, using Laravel to develop the API and admin panel, and another framework for the web client app (next.js/now). I'd optimally like to host them all on the same url: myawesomeapp.com.

Api requests would optimally go to myawesomeapp.com/api/user/ (for example), and the actual web app would route to my next.js, hosted elsewhere, (routes like myawesomeapp.com/profile for example). I assume since much of the server layer is abstracted away if I deploy with Forge, so this wouldn't be possible. However the next best option would be putting my API and admin routes behind subdomains - api.myawesomeapp.com and admin.myawesomeapp.com respectively.

However I'm curious how I could ensure that routes to the root url, simply http://myawesomeapp.com are passed through to my client app (next.js hosted with now)?

Sep
17
1 month ago
Activity icon

Started a new Conversation Guzzle / CURL Connection Refused - Failed To Connect To Port 443

I'm using Guzzle to make a an authorization request to login and seem to be getting connection refused.

My code in my custom controller is

    public function login(Request $request)
    {
        $http = new \GuzzleHttp\Client();
        try {
            $response = $http->post('https://foo.app/oauth/token/', [
                'form_params' => [
                    'grant_type' => 'password',
                    'client_id' => config('services.passport.client_id'),
                    'client_secret' => config('services.passport.client_secret'),
                    'username' => $request->username,
                    'password' => $request->password,
                ]
            ]);
            return $response->getBody();
        } catch (\GuzzleHttp\Exception\BadResponseException $e) {
            if ($e->getCode() === 400) {
                return response()->json('Invalid Request. Please enter a username or a password.', $e->getCode());
            } else if ($e->getCode() === 401) {
                return response()->json('Your credentials are incorrect. Please try again', $e->getCode());
            }
            return response()->json('Something went wrong on the server.', $e->getCode());
        }
    }

and the response I get back is:

[2019-09-17 13:41:57] local.ERROR: cURL error 7: Failed to connect to mixapp.app port 443: Connection refused (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) {"exception":"[object] (GuzzleHttp\Exception\ConnectException(code: 0): cURL error 7: Failed to connect to foo.app port 443: Connection refused (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) at /Users/andrewschorr/Workspaces/laravel_projects/MixApp/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:185)

Has anyone ran into this before? Valet is great, but it abstracts much of this stuff away and makes debugging a bit more of a pain...

Mar
17
7 months ago
Activity icon

Started a new Conversation Is There A Way To Get The Swift_Message Instance From The Mailable Class?

I'd like to be able to extract the email in RFC 2822 format with a $mail->toString() call (as seen here: https://swiftmailer.symfony.com/docs/messages.html), however I'd need to be able to do this on the swift message instance, not the wrapper around it.

Jun
07
1 year ago
Activity icon

Started a new Conversation Valet Not Resolving Sites After Install

Having a terribly frustrating time not having valet working on a fresh install. Going to any *.test site in my browser just hangs and eventually gets the error message This site can’t be reached "ping app.test" hangs as well, and eventually errors with "ping: cannot resolve app.test: Unknown host". However pinging a different domain (such as ping.xyz errors immediately, as opposed to after ~20 seconds like with *.test).

On Os Sierra, my composer.json looks like the following

{
    "require": {
        "laravel/installer": "^1.5",
        "laravel/valet": "dev-master"
    }
}

Since I've seen that dev-master resolved this for some people. All my processes seem to be running:

Services running

However some clues are that http://localhost/ in my browser returns a page 404 - not found, and running sudo nginx returns a bunch of already in user errors:

 ❯ pwd                                                                                                                                                                 
/Users/schorr/.valet

 [email protected] ~/.valet 
 ❯ sudo Nginx                                                                                                                                                          
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)

and valet fetch-share-url returns

❯ valet fetch-share-url                                                                                                                                                [17:04:53]
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
...

Any help is greatly appreciated. thanks!

Jan
28
1 year ago
Activity icon

Replied to Auto Increment Model ID Per User

Well each user would be able to edit their various pages at /page/edit/whatever_INT, would be kind of odd for users two pages to be /page/edit/120 and then /page/edit/459 for example. You'd think semantically each page_id would be per user

Activity icon

Started a new Conversation Auto Increment Model ID Per User

What is the best way to auto increment an ID per user, where the primary key on the model is something like $primaryKey = ['user_id', 'id']?

If using a Page model as an example, so every user can have n amount of pages. If the DB scheme looks like:

        Schema::create('pages', function (Blueprint $table) {
            $table->integer('id');
            $table->timestamps();
            $table->string('name');
            $table->integer('user_id');
        });

When a user adds a new page what is the best way to find the max id of the Page for the current user, and increment by one. And secondly if a user currently has 3 page models in the DB, and then the 2nd one is delete for example, I assume that MySQL best practices would dictate that the next ID should still be 4, even though there is a figurative "hole" at index 2 now?

Jan
20
1 year ago
Activity icon

Replied to Best Way For Including SASS In JavaScript Component

Yah, that makes sense. I was really hoping to have my entire client side setup component-ized and keep all the SASS alongside the style sheets.... I may as well try and get css-react modules working in my app.

Activity icon

Started a new Conversation Best Way For Including SASS In JavaScript Component

Laravel Mix is working great to transform and concat global stylesheets, such as app.scss that is included in a fresh install, but I was curious about best practices for including component-related styles, especially with respect to a localized react component. Say for instance the first couple lines of my component look like

import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import './index.scss';

export default class Example extends Component {
...

Currentlt index.scss ends up inputting inline in a script tag... What's the best way to combine related components into a single stylesheet, and what about deployment?

Jan
18
1 year ago
Activity icon

Started a new Conversation Class Name Does Not Match Style Name With Babel-plugin-react-css-modules

I'm trying to add babel-plugin-react-css-modules to my webpack project and the style names don't seem to match the class names in both at the front the weird hyphen/underscore in the style class names, and then the differing hash at the end. Curious where these are generated for the dom markup since my webpack config looks like

rules.push({
    test: /\.css$/,
    exclude: Config.preprocessors.postCss ? Config.preprocessors.postCss.map(postCss => postCss.src.path()) : [],
    loaders: ['style-loader', 'css-loader?importLoader=1&modules&localIdentName=[path]___[name]__[local]___[hash:base64:5]'],
});

Also using Laravel Mix to complicate things which abstracts the webpack config in https://github.com/JeffreyWay/laravel-mix/blob/master/src/builder/webpack-rules.js

enter image description here

Any help is appreciated!

Activity icon

Started a new Conversation Babel-plugin-react-css-modules Not Transforming StyleName In React

In an attempt to get babel-plugin-react-css-modules working, I can't seem to get the styleName prop on react elements to be transformed to the correct thing. Regular CSS modules work fine, so when the DOM looks like:

    <div className={style.a}>hello</div>

The complied code looks like:

    <div class="_-_-_-_-resources-assets-js-components- ___index__a___1TazJ">hello</div> 

However, switching it to:

    <div styleName='a'>hello</div>  

Doesn't transform it at all... I'm using laravel mix, on top of laravel so my CSS loader looks like:

     // CSS Compilation.
    rules.push({
        test: /\.css$/,
        exclude: Config.preprocessors.postCss ? Config.preprocessors.postCss.map(postCss => postCss.src.path()) : [],
        loaders: ['style-loader', 'css-loader?importLoader=1&modules&localIdentName=[path]___[name]__[local]___[hash:base64:5]']
    });

What in the world am I missing!?

Aug
11
2 years ago
Activity icon

Replied to Best Way To Abstract Passing Data From Controller To View->template

@Snapey Awesome! That seems to work... I added that method to the base level abstract class Controller.

What's the best practice adding methods to that and other lower-level classes? I'm curious of the situation when the next Laravel update is released, will updating to any future version wipe away all changes to Controller class?

Aug
10
2 years ago
Activity icon

Started a new Conversation Best Way To Abstract Passing Data From Controller To View->template

Decently new to laravel and I'm pulling my hair out looking for the best way to abstract setting variables in the controller that would be accessed in the view and blade templates. This all stems from an easy way to dynamically include JS bundles in the blade file - the hope is in the controller it would be something like:

AuthController.php

$this->setContext('album_page');

and then in the blade file, something along the lines of app.blade.php

@if (isset(context))
     <script src="'js/bundles/{{ context }}.js') }}"></script>
@endif 

I'd optimally like to avoid shoving it in the view function, since that would be kind of messy in every controller method that renders a view... I know I could do something in the provider, like:

        view()->composer('layout.app', function($view){
            $view->with('context', not_entirely_sure_how_to_access_controller_here...);
        });

Thanks all! :)