steveperrycreative

steveperrycreative

Designer / Developer at Steve Perry Creative Limited

Brown Edge

Hire Me

Member Since 4 Years Ago

Experience Points 39,315
Experience
Level
Lessons Completed 570
Lessons
Completed
Best Reply Awards 0
Best Answer
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.

05 May
1 year ago

steveperrycreative left a reply on Ideas To Store Record Activity Logs?

If you are talking about what I think you are talking about then Jeff just covered something like this in the Forum series:

https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/25

steveperrycreative left a reply on Static::deleting In A Boot Method Is Not Working In Test

I should add that when I perform the task in a browser it works as expected so it is just the test that isn't working.

steveperrycreative started a new conversation Static::deleting In A Boot Method Is Not Working In Test

This is my test:

    /** @test */
    public function deleting_a_task_from_a_project_restores_its_credits()
    {
        $this->signInAsAdmin();

        $project = factory('App\Project')->create();

        $task = factory('App\Task')->create([
            'project_id' => $project->id,
            'credits_used' => 20
        ]);

        $project->credits = 100;
        $project->save();

        $response = $this->json('DELETE', $task->path());

        $response->assertStatus(204);

        $this->assertTrue($project->credits == 120);
    }

My destroy method on the TasksController is:

public function destroy(Task $task)
    {
        $project = $task->project;

        $this->authorize('update', $project);

        $task->delete();

        if (request()->wantsJson()) {
            return response([], 204);
        }

        return redirect($project->path());
    }

And my boot method on the Task model is:

protected static function boot()
    {
        parent::boot();

        static::creating(function ($task) {
            $task->project->removeCredits($task->credits_used);
        });

        static::deleting(function ($task) {
            $task->project->addCredits($task->credits_used);
        });
    }

The add and remove credits methods just perform some basic maths and save, nothing fancy. When I test creating a task the credits get removed from the project as expected. However when I run the above delete test nothing happens to the credits on the project, they stay at 100.

The boot method runs fine. I've even tried sliming it by just doing:

    static::deleting(function ($task) {
        $task->project->credits = 120;
        $task->project->save();
    });

But that doesn't work either. I'm stumped. Am I missing something silly!?

21 Apr
1 year ago

steveperrycreative left a reply on How To Store Time, And Manipulate It -- Not Time Travel Related ;)

@Snapey that's exactly why I posted here, to get a fresh perspective like that. Thinking of it as credits makes it much easier to get my head around it, thank you.

20 Apr
1 year ago

steveperrycreative left a reply on How To Store Time, And Manipulate It -- Not Time Travel Related ;)

I have yes, thank you, and will be storing time as a Carbon instance but I'm unsure of where to store it. I.e. would it be better on the Task(s), Project or would it be better to have a Time model? Or something completely different.

steveperrycreative started a new conversation How To Store Time, And Manipulate It -- Not Time Travel Related ;)

I'm re-writing an application for my business which helps me manage website maintenance plans for my clients.

These plans differ, depending upon what the client requires. Some are just software updates and some include discounted monthly hours of my time. Standard stuff.

I add projects to the application, which then have tasks added to them and I have a plan associated to the project. Those tasks, when added, subtract time from the client's accumulated balance of hours. The balance of hours should auto-accumulate each month based upon the associated plan.

To complicate matters a little, some of these plans have their hours reset after 3 months of accumulation, but not all of them.

Project views show all tasks (with time used on them), the current plan, accumulated hours and hours/mins remaining.

My question is how should I store this time so that I can retrieve it and manipulate where required. It would be nice if I could even retrieve the hours that have been reset (just for reports etc).

In the past I just stored a number which related to the number of hours allowed each month and did some basic maths when loading the views but this was obviously very restricted so I'm keen to hugely improve in v2.

Should I create a Time model? How would this work with a cron, which I guess I'll also need to keep the hours adding up in the background?

Any pointers really appreciated as I'm struggling to get my head around it a bit. I'm still relatively new to Laravel and OOP in general.

26 Aug
2 years ago

steveperrycreative left a reply on Warranty Period For Websites

No at all @TheNephilim but I make sure that I communicate it well from the start. Most clients take out maintenance plans so it's not really an issue for them.

25 Aug
2 years ago

steveperrycreative left a reply on Warranty Period For Websites

Personally I tell clients it's 30 days from launch and make it clear that it's wise to take out a maintenance plan. I'm a sucker for just fixing stuff like you mention though, after 30 days, and quite often get taken advantage of because I'm always keen to keep clients happy. It's fine as long as you keep a healthy balance and communicate well.

15 Feb
2 years ago
14 Feb
2 years ago

steveperrycreative started a new conversation User Registration Email Confirmation Issue

I've been following this tutorial on adding user registration email confirmation but instead of creating my own registration controllers I'm using an amended version of Laravel's auth controllers, bringing it inline with Jeffrey's custom version.

However when a user registers I receive the following error:

ErrorException in AuthController.php line 67:
Argument 2 passed to Prolinked\Http\Controllers\Auth\AuthController::create() must be an instance of Prolinked\Mailers\AppMailer, none given, called in /Users/steve/Server/jasoncampbell/vendor/laravel/framework/src/Illuminate/Foundation/Auth/RegistersUsers.php on line 59 and defined

Which I'd kind of expect but then Jeffery's version is the same and as far as I can tell his route isn't passing a 2nd argument through either but he is not getting this error. Am I missing something from somewhere else perhaps?

My AuthController is:

<?php

namespace Prolinked\Http\Controllers\Auth;

use Validator;
use Prolinked\User;
use Prolinked\Mailers\AppMailer;
use Prolinked\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;

class AuthController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Registration & Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles the registration of new users, as well as the
    | authentication of existing users. By default, this controller uses
    | a simple trait to add these behaviors. Why don't you explore it?
    |
    */

    use AuthenticatesAndRegistersUsers, ThrottlesLogins;

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

    /**
     * Create a new authentication controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest', ['except' => 'logout']);
    }

    /**
     * Get a validator for an incoming registration request.
     *
     * @param  array  $data
     * @return \Illuminate\Contracts\Validation\Validator
     */
    protected function validator(array $data)
    {
        return Validator::make($data, [
            'firstname' => 'required|max:255',
            'lastname' => 'required|max:255',
            'email' => 'required|email|max:255|unique:users',
            'password' => 'required|confirmed|min:6',
        ]);
    }

    /**
     * Create a new user instance after a valid registration.
     *
     * @param  array  $data
     * @param  AppMailer  $mailer
     * @return User
     */
    protected function create(array $data, AppMailer $mailer)
    {
        $user = User::create([
            'firstname' => $data['firstname'],
            'lastname' => $data['lastname'],
            'email' => $data['email'],
            'password' => bcrypt($data['password']),
        ]);

        $mailer->sendEmailConfirmationTo($user);

        flash('Please confirm your email address.');

        return redirect()->back();
    }

    /**
     * Listen for our user creation and add our token during that process.
     */
    public static function boot()
    {
        parent::boot();

        static::creating(function($user) {
            $user->token = str_random(30);
        });
    }
}

Let me know if you need to see any other code.

27 Jul
3 years ago

steveperrycreative left a reply on Problem Uploading File With Laravel Excel

Fantastic, thank you! Worked a treat.

steveperrycreative started a new conversation Problem Uploading File With Laravel Excel

I'm trying to upload a file and add the contents to my database using Laravel Excel. The file is uploaded using a form which posts to my uploadFromCsv method.

When I upload the file I get:

PHPExcel_Reader_Exception in Excel2007.php line 82: Could not open for reading! File does not exist.

My form is:

<form class="form-horizontal" method="POST" action="/ascents/upload">
    {!! csrf_field() !!}
    <div class="form-group">
        <label for="file" class="col-sm-3 control-label">Select CSV File</label>
        <div class="col-sm-9">
            <input type="file" class="form-control" id="file" name="file">
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-3 col-sm-9">
            <button type="submit" class="btn btn-default">Upload</button>
        </div>
    </div>
</form>

And my method is:

    public function uploadFromCsv()
    {
        Excel::load(Input::file('file'), function ($reader) {
            foreach ($reader as $log) {
                $ascent = new Ascent($log->all());
                Auth::user()->ascents()->save($ascent);
            }
        });
        return redirect(route('ascents'));
    }
21 Jul
3 years ago

steveperrycreative left a reply on PHP Books

@polarcubs I think that is possibly one of the longest resource lists I've seen. Thanks for the recommendation.

Thanks everyone, I've started with @ian_h's and Jeffrey's recommendation of PHP Objects, Patterns, and Practice and will work through the rest. It's great so far, really easy to understand and very well written.

20 Jul
3 years ago

steveperrycreative left a reply on PHP Books

Thanks, Ian. They don't have to be Laravel-specific.

steveperrycreative started a new conversation PHP Books

I'm relatively new to object oriented PHP but I'm slowly beginning to understand the basic principles and I'm comfortable setting up basic classes, methods and putting them to use.

I'd like to start learning more about patterns, conventions and testing. I really enjoy the videos on here and would like some recommendations for some off-screen learning (books!) which are steady enough for a relative beginner.