0 Best Reply Awards

  • Member Since 1 Year Ago
  • 3 Lessons Completed
  • 0 Favorites

16th October, 2018

murph133 left a reply on Laravel Eloquent Sort By Related Field • 1 day ago

The ordering methods mentioned above did not work for me using Laravel 5.6

However, I found a solution to orderBy a relation model using counts.

I wanted to order my business listings by their membership_level:

  1. Premium Plus
  2. Premium
$businesses = Business::withCount('subscription_premium_plus')->withCount('subscription_premium_plus')->orderBy('subscription_premium_plus_count', 'desc')->orderBy('subscription_premium_count', 'desc')->get();

Then I had two methods in my Business model:

public function subscriptionPremiumPlus()
    return $this->hasOne('App\Subscription')->where('end_date', '>', Carbon::now())->where('membership_level', 2);
public function subscriptionPremium()
    return $this->hasOne('App\Subscription')->where('end_date', '>', Carbon::now())->where('membership_level', 1);

My personal code actually included another relationship, but I have simplified things so you get the basic idea of what I did. Using the custom relationship methods also allowed me to add conditionals, such as checking whether the subscription was still valid.

13th June, 2018

murph133 left a reply on Very Very Slow To Speed Up • 4 months ago

Make sure you have indexes on your tables.

$table->index('user_id'); // Example migration code

Add the indexes and test again to see if there's a performance difference. My load time dropped by over 50%, when I added indexes to the related tables that were being used for the withCount.

11th June, 2018

19th May, 2018

murph133 left a reply on BindingResolutionException In Container.php • 4 months ago

@rawrkats I had exactly the same.


protected function __construct()


public function __construct()

murph133 left a reply on BindingResolutionException And Target Is Not Instantiable • 4 months ago

I did not find the solution, but using a different controller worked. So that's an option, if you're pressed for time.

8th May, 2018

murph133 left a reply on [Laravel 5.4] How To Get The Current HTTP Status Code In 404 Error Page? • 5 months ago

I am having the same problem. Cannot find a solution. Laravel is therefore returning a "soft 404", which is bad practice, according to Google.

7th May, 2018

murph133 left a reply on [Guide 5.2.x] Make Session Work In Error Pages • 5 months ago

Thank you, great help.

I also had to move \Illuminate\View\Middleware\ShareErrorsFromSession::class,

4th May, 2018

murph133 left a reply on TokenMismatchException With Big Files • 5 months ago


Yes, you need to update your php.ini file.

Yes, increase the upload_max_filesize and post_max_size, but ALSO increase the max_execution_time.

I had a problem when a user tried to upload a 13mb image. When I increased the max_execution_time from 30 to 90 seconds, this resolved the issue.

12th February, 2018

murph133 left a reply on Give An Email A Subject! • 8 months ago

If you want to use a variable from your model in subject(), just do the following:

return $this->markdown('event.approved')->subject("Your event is live: ". $this->event->title);

In this case, we're sending them an email when the event has been approved and made like. We add the event title into the email subject.

murph133 left a reply on Object Of Class App\Mail\PasswordRecovery Could Not Be Converted To String • 8 months ago

I had the same problem when I tried to use the preview.

The reason: my version of Laravel is 5.4, not 5.5!

This feature is not available in 5.4.

Instead, in my routes, I returned the view with the data, rather than the class.

1st February, 2018

murph133 left a reply on Error 500 In Laravel On Shared Hosting • 8 months ago

I recommend checking the server error logs.

I discovered the follow error: SoftException in Application.cpp:261: File "/home/wpwfcom/public_html/my_project_name/index.php" is writeable by group

When I changed the file permission of the index.php file from 664 to 644, this resolved this particular problem. No more 500 error.

17th August, 2017

murph133 started a new conversation Spark > Cashier > Stripe > Subscriptions: Changing The Default Address Country • 1 year ago

The default subscription country for Stripe is US.

I want to change this to GB - for the United Kingdom, where all of my customers are based.

I have tried to customise this by changing a few view files that were hardcoded with the "US" as the default country.

I ran "npm run dev" after every edit.

No change in the Stripe logs for the new subscriptions I set up.

murph133 left a reply on Spark - Invoices Not Generating • 1 year ago

To receive invoices, you require a Stripe webhook:

Example "URI to be called":

The same applies for Braintree.

14th August, 2017

murph133 left a reply on [L5] Avoiding CSRF Middleware On API POST Routes • 1 year ago

Thank you @billmn.

I had a problem integrating a GoCardless API into Laravel 5.4.

My server was responding with a 500 internal server error.

Adding the uri of my webhook to /Middleware/VerifyCsrfToken.php solved the problem.

7th August, 2017

murph133 left a reply on SQLSTATE[42S01]: Base Table Or View Already Exists: 1050 Table 'users' Already Exists • 1 year ago

Step 1

php artisan migrate:reset

Step 2

Go to your database using PHPmyadmin (or similar) and delete all remaining tables - including the migration table.

Step 3

php artisan migrate

30th July, 2017

murph133 left a reply on ErrorException In Helpers.php Line 582: The Mix Manifest Does Not Exist. • 1 year ago

The approach of mrad worked for the me.

Thank you!

Edit Your Profile

Want to change your profile photo? We pull from