Randy_91

Randy_91

Member Since 1 Week Ago

Experience Points 190
Experience Level 1

4,810 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 0
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

12 Jun
5 days ago

Randy_91 started a new conversation Auth Scaffolding RedirectTo Doesn't Work

Using the default laravel auth scaffolding in 5.8 in the LoginController theres a variable :

/** * Where to redirect users after login. * * @var string */ protected $redirectTo = '/home';

I have changed this to '/dashboard' yet it still redirects me to home.

How do I fix that?

Randy_91 left a reply on What Is The Best Way To Consume A REST API In Laravel 5.8

use GuzzleHttp\Client;

class RestAPI { protected $url; Protected $accessToken; protected $client; protected $headers;

public function __construct(Client $client)
{
    $this->url = 'https://gorest.co.in/public-api/';
    $this->accessToken = env('GOREST_ACCESS_TOKEN');
    $this->client= $client;
    $this->headers = [
        'cache-control' => 'no-cache',
        'content-type' => 'application/x-www-form-urlencoded',
    ];
}

public function getRequest(string $uri = null)
{
    $full_path = $this->url;
    $full_path .= $uri.'?access-token='.$this->accessToken;

    $request = $this->client->get($full_path, [
        'headers'         => $this->headers,
        'timeout'         => 30,
        'connect_timeout' => true,
        'http_errors'     => true,
    ]);

    $response = $request ? $request->getBody()->getContents() : null;
    $status = $request ? $request->getStatusCode() : 500;

    if ($response && $status === 200 && $response !== 'null') {
        return (object) json_decode($response);
    }

    return null;
}

public function postRequest(string $uri = null, array $post_params = [])
{
    $full_path = $this->url;
    $full_path .= $uri;

    $request = $this->client>post($full_path, [
        'headers'         => $this->headers,
        'timeout'         => 30,
        'connect_timeout' => true,
        'http_errors'     => true,
        'form_params'     => $post_params,
    ]);

    $response = $request ? $request->getBody()->getContents() : null;
    $status = $request ? $request->getStatusCode() : 500;

    if ($response && $status === 200 && $response !== 'null') {
        return (object) json_decode($response);
    }

    return null;
}
11 Jun
6 days ago

Randy_91 started a new conversation What Is The Best Way To Consume A REST API In Laravel 5.8

I am quite new to Laravel and need to consume a REST API and display the data on a page. Is there a specific modern way of doing this in 5.8 such as resources or is it just a case of using guzzle?

06 Jun
1 week ago

Randy_91 left a reply on Application Structure And Business Rules

As I said not asking for help with the code but what I am looking for is suggestions on where business logic like this should go or how it should be structured.

Randy_91 left a reply on Application Structure And Business Rules

What do you mean "But thats all there really is to it"?

The idea is to demonstrate a variety of PHP language features and practices while building this so it's, not just a simple case of hacking together a quick script. I agree with the TDD approach but there must be a good way to structure the rules.

Randy_91 left a reply on Application Structure And Business Rules

Seems good, still doesn't really answer my questions though.

Randy_91 started a new conversation Application Structure And Business Rules

I am building an application that keeps track of when people within our organisation should get a birthday present.

The application takes an input text file containing a list of dates of birth, in the following format with one entry per line:

Person Name, yyyy-mm-dd

The application will output a CSV file containing the dates we have birthday presents for the current year.

“Present Days” are calculated according to the following rules:

A present is provided on the employee’s first working day after their birthday. All employees get their birthday off The office is closed on weekends, Christmas Day, Boxing Day and New Year’s Day If the office is closed on an employee’s birthday, they get the next working day off. If two or more birthdays coincide, we instead provide one large cake to share. If there are to be presents two days in a row, we instead provide one large present on the second day. The day after each day a present is given must be a present free day. Any presents due on a present free day are postponed to the next working day. There is never more than one present a day.

It would be easy enough to write this application raw PHP and put the above business rules in a function with a big bunch of if and else statements or a switch. But how would I go about structuring this properly in laravel?

Where would I put the logic for the rules and I assume there are packages available that will help with the working days etc.

I am not looking for help in coding this up just high-level help about how to go about structuring this application.