FrankClark

FrankClark

Member Since 2 Years Ago

Experience Points
4,750
Total
Experience

250 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
25
Lessons
Completed
Best Reply Awards
3
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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
4,750 XP
Aug
03
1 month ago
Activity icon

Replied to Eloquent : Scope WhereIn Matches All (relation)

Great thank you @michaloravec , this works. And very quick response. I also found that the following works just now but I haven't fully tested it :

public function scopeAvailableBetween(Builder $query, string $startDate, string $endDate): Builder
    {
        $periodDates = CarbonPeriod::create($startDate, $endDate);
        $datesBetween = [];
        foreach ($periodDates as $date) {
            $datesBetween[] = $date->format('Y-m-d');
        }

        $query->with('roomAvailabilties');
        foreach($datesBetween as $date){
            $query->whereHas('roomAvailabilties', function($q) use ($date){
                $q->where('date', $date);
            });
        }
        return $query;
    }
Activity icon

Started a new Conversation Eloquent : Scope WhereIn Matches All (relation)

Hello There,

I have a table rooms And a table room_availabilities

A room has many room room_availabilities with foreign key room_id

A room availability basically made up of room_id and date. There is an entry for each available date for that room.

I want to have query scope that checks to see if all dates in an array are available and will only return the room if all dates are available. What do I need to do to achieve this. The below obviously won't have the desired effect because it will just return the rooms where it has one of those dates. I want it to match all of them or exclude the room.

 public function scopeAvailableBetween(Builder $query, $dates): Builder
    {
        $startDate = $dates[0];
        $endDate = $dates[1];
        $periodDates = CarbonPeriod::create($startDate, $endDate);
        $datesBetween = [];
        foreach ($periodDates as $date) {
            $datesBetween[] = $date->format('Y-m-d');
        }

        $query->with('roomAvailabilties')->whereIn('room_availabilities.date', $datesBetween);
    }
Jul
10
2 months ago
Activity icon

Awarded Best Reply on Code Review: Made A Simple Package

When your function has no return, you can use the void return type hint

 public function __construct(Client $client = null): void
 {
    $this->client = $client ?: new Client();
 }

Also if your method returns $this you can use return type hint of self e.g.

public function jokes(int $count = 2): self
    {
        $this->ipsum .= $this->jokesIpsum->jokes($count);

        return $this;
    }

This will just aid your IDE along.

Instead of const API_ENDPOINT = 'http://api.icndb.com/jokes'; you could use an environment variable or config. See Laravel's documentation here : https://laravel.com/docs/5.8/packages#configuration this way you can publish your configuration for the package and the endpoint could be modified per installation

Jun
11
3 months ago
Activity icon

Replied to Laravel 7 CORS Configuration Issue Axios - External Api

Weirdly i switched to a different images API and everything now works, might just be the pixabay server, but can't confirm anything on google.

I'll mess around with apache config and see where I get. Can't find anything in Homestead documentation about it.

Activity icon

Started a new Conversation Laravel 7 CORS Configuration Issue Axios - External Api

Hello There,

I am having a CORS issue, which seems to be the case every time I create a Laravel project. I've thrown a lot of sh*t at the wall but so far nothing has stuck.

Laravel 7 now apparently has CORS built in, and I believe I have it configured correctly. I have made some changes to the configuration in an attempt to force it to work. Here is my config :

<?php
return [

    'paths' => ['*'],
    'allowed_methods' => ['*'],
    'allowed_origins' => ['*'],
    'allowed_origins_patterns' => ['*'],
    'allowed_headers' => ['*'],
    'exposed_headers' => [
        'Cache-Control',
        'Content-Language',
        'Content-Type',
        'Expires',
        'Last-Modified',
        'Pragma',
    ],
    'max_age' => 0,
    'supports_credentials' => false,

];

In my bootstrap.js I have

window.axios = require('axios');

window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
window.axios.defaults.headers['crossDomain'] = true;
window.axios.defaults.headers['Access-Control-Allow-Origin'] = '*';

let csrf = document.querySelector('meta[name="csrf-token"]');
if (csrf) {
    window.token = csrf.getAttribute('content');
    window.axios.defaults.headers.common["X-CSRF-TOKEN"] = window.token;
} else {
    console.error("CSRF token not found!")
}

My actual axios request (included the headers again to be sure)

axios.get(`https://pixabay.com/api?key=17006889-26607170fc9b6e04fb874a7cb&=house`, {headers: {
                      'crossDomain': true,
                      'Access-Control-Allow-Origin': '*',
                      'Content-Type': 'application/json',
                      'Access-Control-Allow-Methods': 'POST, GET, OPTIONS, PATCH, PUT',
                  },}).then((response) => {
                  console.log(response.data);
                  return response.data[0].imageURL;
              }).catch((error) => {

              });

I am also using latests Homestead.

Any advise would be greatly appreciated.

May
01
4 months ago
Activity icon

Replied to Problem After Composer Update

I can't imagine that anyone else reading this is a stupid as I was but just in case... I had accidentally removed "laravel/framework": "^5.6" from my composer.json when resolving merge conflicts.