fogley

fogley

Member Since 1 Year Ago

Experience Points 850
Experience Level 1

4,150 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.

08 Apr
2 months ago

fogley left a reply on Multiple Queue Workers Borks The System

Setting retry_after solved it. These jobs can last days, so I upped it to a week. Thanks.

03 Apr
2 months ago

fogley started a new conversation Multiple Workers Borks The System

As soon as I run more than 1 worker on my server, they all jump on the first job they see and make it fail because it exceeds the retries (which is 1). The first job to grab it will keep working as though nothing happened, making the database inconsistent...

I thought Laravel was capable of handling multiple workers by default. Why are they taking up already running jobs? Am I missing something?

19 Dec
6 months ago

fogley left a reply on Custom Save Method For Model Returning False On Unique Constraint Violation

@AHMEDDABAK - uniqid is an (at least) 13 character long string which is not viable for me. I need to be able to create unique strings of 5 characters in length.

fogley left a reply on Custom Save Method For Model Returning False On Unique Constraint Violation

@AHMEDDABAK - The thing is, the data created is a randomized string used as an identifier, there's nothing to redirect to. This is only used in internal loops to create an entry with valid data:

while(!$model->saveOrFalse()){
    $model->identifier = str_random(5);
}

fogley started a new conversation Custom Save Method For Model Returning False On Unique Constraint Violation

So, I'm a little tired of constantly combating whether or not I'm currently about to violate a unique constraint in my database. As an experiment I've made the following model function that silently processes the QueryException and returns false if one such (among other errors falling under QueryException) should occur.

    public function saveOrFalse(){
        try{
            return $this->save();
        }catch(QueryException $e){
            return false;
        }
    }

It works precisely as I would expect and could end up lighten my workload a lot.

But I really want to know: How bad practice is this? Is the overhead massive compared to checking prior to saving?

Assuming it's out of the question for any sane developer, do you have any alternatives?

14 Nov
7 months ago

fogley left a reply on Dd Converts Large Associative Array To Numeric?

Around 60.000 elements.

I've been doing some tests and the values in the numeric array corresponds to the ones in the associative array...

I have a very hard time seeing how this is in any way handy... Unless I'm missing something.

13 Nov
7 months ago

fogley started a new conversation Dd Converts Large Associative Array To Numeric?

I've been dumping a lot of test data and it seems that dd converts associative arrays to numeric when the amount of data exceeds a certain threshold. Is that correct?

06 Nov
7 months ago

fogley started a new conversation Cannot Drop Column And Add New Columns In Same Migration

I've created a migration that is supposed to drop columns as well as create new ones. When I drop the column, the migration does not add the the columns.

When I remove the dropColumn call, the columns are added just fine. I use SQLite.

Here's the simplified version:

    Schema::table('table', function($table) {
        $table->integer('new_column_name')->nullable();
        $table->dropColumn('old_column_name');
    });
05 Nov
7 months ago

fogley started a new conversation Parse Date According To Specific Format

I trying to parse user submitted dates that vary wildly in format. So, to accommodate this I enable users to set the used format so that the system can save dates in a consistent format.

But, I cannot figure out if it's at all possible to tell Carbon to parse an arbitrary date string in a given format. And, if not: Is there any other realistic solution to this problem?

30 Oct
7 months ago

fogley left a reply on Cannot Call Custom Job Method Withing Job Itself

This is the gist of it:

$db_data = Model::all();
$db_data->where('column', 'value')->exists();

Using first() instead of exists() solved the problem.

fogley left a reply on Cannot Call Custom Job Method Withing Job Itself

Turns out I was using the exists() method on an already declared DB collection. So, I ended up using the first() method instead and treating the returned data as a boolean.

Is this an oversight? Why can't I use the exists() method on existing collections?

fogley started a new conversation Cannot Call Custom Job Method Withing Job Itself

I have created a Job containing a few helper methods, contained within the job class itself. When I try to call the methods ($this->method($params);), I get an error that the method does not exist.

Any ideas?

16 Oct
8 months ago

fogley left a reply on Only Process Jobs One At A Time

Ah, okay. Thanks!

fogley started a new conversation Only Process Jobs One At A Time

I want to process jobs chronologically, as in: Only one job running at any given time.

Is it correct if I assume that this is done by adding the --once option to the worker?

php artisan queue:work --once

15 Oct
8 months ago

fogley started a new conversation Text Cells With Special Characters Has A 'b' Character Prefixed To String Using SQLite

When I text data from my SQLite DB with special characters (ä), the string containing the character has the character b prefixed to the string, dd'ing the data looks like this:

"column_name" => b"text containing ä"

This doesn't print anything when printed in views.

Any fixes?

fogley started a new conversation Fetch Model Where Relationship Model Has Specific Values

I'm trying to fetch records with specific values as well as specific values related to their belongsTo model.

So, I would write it like so:

$records = Records::where('belongsto.column', 'value')->orWhere('column', 'another_value')->get();

Is there a way to do this or do I need to chop it up?

11 Oct
8 months ago

fogley left a reply on Jobs Cant Use The Info() Helper Function

Ah. It seems I need to restart the queue worker when I've made changes to the Job class. Makes sense.

fogley left a reply on Jobs Cant Use The Info() Helper Function

That also does nothing...

fogley started a new conversation Jobs Cant Use The Info() Helper Function

I debugging a Job class, but I can't get it to write to the log using the info() helper function. My controllers can do so with no problem...

Solutions?

07 Sep
9 months ago

fogley left a reply on Redirect With Data

I cannot fetch the data transferred like this. If I reference it like this {{ $variable }} it returns an error because it's undefined.

fogley left a reply on Redirect With Data

That transfers the data via GET which I'm not interested in...

fogley started a new conversation Redirect With Data

Is there a way to pass data to a redirection in the same vein as when returning views?

Like this

return redirect->('/home')->with('variable', 'variable data')

05 Sep
9 months ago
04 Sep
9 months ago

fogley left a reply on Getting Distinct Data Based On Specific Columns

I updated the original post to better reflect what I need help with.

fogley left a reply on Getting Distinct Data Based On Specific Columns

Isn't that exactly what the latest() method is for?

fogley started a new conversation Getting Distinct Data Based On Specific Columns

Right now, when I run distinct on my query it will fetch the whole table. I suspect this is because I have timestamps enabled. So even though all the important columns are the same, the query will treat the data as different because it contains different timestamps. I am only interested in the unique data set, disregarding the timestamps.

Is there a way to tell the query builder to only observe specific columns when deciding whether or not data is distinct?

How would I combine this with only retrieving the newest distinct data?

03 Sep
9 months ago

fogley started a new conversation Can I Really Not Pass A Multidimensional Array To WhereIn? - Creating Dynamic WhereIn Clauses

I've been fighting with how to dynamically create a database query with potentially many whereIn clauses. So, I tried feeding the method a multidimensional array like so:

´Users::whereIn(['id' => [1,2,3], 'email' => ['[email protected]', '[email protected]']])->get();´

How the above should work is obvious to me (I hope it is for you as well).

So, seeing as this does not work, how would I go about making a dynamically created whereIn clause?

The only solution I can think of is a n ungodly if/else with all possible outcomes, but that hurts my brain.

15 Jun
1 year ago

fogley left a reply on Access Forbidden On Non-HTTPS Connections In Apache

Yeah, that config is initially why I started tweaking it. It didn't work either.

11 Jun
1 year ago

fogley started a new conversation Access Forbidden On Non-HTTPS Connections In Apache

I have a 5.5 installation running on a virtual host in Apache 2, encrypted by Certbot/LetsEncypt.

The HTTPS access works just fine, but accessing it through HTTP poses problems:

Even though I activated automatic redirect when installing the certificate, the server does not redirect to a secure connection. - Instead, Apache simply returns a forbidden error.

I have tried different tweaks in both the virtualhost config as well as in Laravel's own .htaccess with no luck. Do you guys have any idea how to resolve this/enabling a working HTTP to HTTPS redirect?

Below is my virtualhost config (I tried tweaking the redirect clause, so it's not the default Certbot version):

        DocumentRoot /var/www/[domain.tld]/public
    ServerName [domain.tld]

        <Directory /var/www/[domain.tld]/public>
            Options -Indexes
            AllowOverride All
            Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        <IfModule mod_dir.c>
            DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
        </IfModule>

        RewriteEngine on
        RewriteCond %{HTTPS} !=on
        RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]