ohffs

ohffs

Glasgow

Member Since 3 Years Ago

Experience Points 262,950
Experience
Level
Lessons Completed 979
Lessons
Completed
Best Reply Awards 288
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.

13 Nov
19 hours ago

ohffs left a reply on Docker, Laravel And A Production Server With Apache Running

I'm running stuff on our staging server just now doing this (we've not been quite brave enough to push the setup to production though). We've got :

  • a docker-compose.yml file for each app that sets up the app, scheduler, queues and adds some keys for -
  • traefik which takes care of routing incoming requests to the correct containers.

Our dockerfile setup is based on the idea from this laravel news article.

Our docker-compose.yml file ends up like this :

version: "3"
services:
  app:
    image: localhost:5000/someapp-web
    container_name: someapp-web
    build:
      context: .
      dockerfile: docker/Dockerfile
    depends_on:
      - redis
      - mysql
    networks:
      - proxy
      - private
    expose:
      - "80"
    environment:
      APP_ENV: local
      CONTAINER_ROLE: app
      DB_CONNECTION: mysql
      DB_HOST: mysql
      DB_DATABASE: someapp2
      DB_USERNAME: homestead
      DB_PASSWORD: secret
      CACHE_DRIVER: redis
      SESSION_DRIVER: redis
      QUEUE_DRIVER: redis
      REDIS_HOST: redis
      DEFAULT_DISK: images
    deploy:
      replicas: 3
      labels:
        - "traefik.backend=someapp-web"
        - "traefik.docker.network=proxy"
        - "traefik.frontend.rule=Host:someapp.staging.our.domain.com"
        - "traefik.enable=true"
        - "traefik.port=80"
        - "traefik.default.protocol=http"

  scheduler:
    image: localhost:5000/someapp-web
    container_name: someapp-scheduler
    depends_on:
      - app
    deploy:
      labels:
        - "traefik.enable=false"
    networks:
      - private
    environment:
      APP_ENV: local
      CONTAINER_ROLE: scheduler
      DB_CONNECTION: mysql
      DB_HOST: mysql
      DB_DATABASE: someapp2
      DB_USERNAME: homestead
      DB_PASSWORD: secret
      CACHE_DRIVER: redis
      SESSION_DRIVER: redis
      QUEUE_DRIVER: redis
      REDIS_HOST: redis
      DEFAULT_DISK: images

  queue:
    image: localhost:5000/someapp-web
    container_name: someapp-queue
    depends_on:
      - app
    deploy:
      replicas: 2
      labels:
        - "traefik.enable=false"
    networks:
      - private
    environment:
      APP_ENV: local
      CONTAINER_ROLE: queue
      DB_CONNECTION: mysql
      DB_HOST: mysql
      DB_DATABASE: someapp2
      DB_USERNAME: homestead
      DB_PASSWORD: secret
      CACHE_DRIVER: redis
      SESSION_DRIVER: redis
      QUEUE_DRIVER: redis
      REDIS_HOST: redis
      DEFAULT_DISK: images

  redis:
    container_name: someapp-redis
    image: redis:4
    deploy:
      labels:
        - "traefik.enable=false"
    networks:
      - private
    volumes:
      - redis:/data

  mysql:
    container_name: someapp-mysql
    image: mysql:5.7
    deploy:
      labels:
        - "traefik.enable=false"
    networks:
      - private
    volumes:
      - mysql:/var/lib/mysql
    environment:
      MYSQL_DATABASE: someapp2
      MYSQL_ROOT_PASSWORD: root
      MYSQL_USER: homestead
      MYSQL_PASSWORD: secret

volumes:
  redis:
    driver: "local"
  mysql:
    driver: "local"

networks:
  private:
  proxy:
    external: true

12 Nov
1 day ago

ohffs started a new conversation Has Anyone Used 'vue-mc'?

Came across vue-mc the other day and it looks like it might be quite good for when ajax/api stuff goes beyond a couple of simple calls. It reminds me a little of using mongoose for node/mongodb.

Anyway - just wondering if anyone here had used it and what the experience was like before I spend too much time trying it out myself only to hit some big cliff-edge 'gotcha' with it ;-)

10 Nov
3 days ago

ohffs left a reply on All Problems With The New Laracasts Design

@SNAPEY - Thanks for fixing the notification scrolling/clear all, Jeffrey :-). A+++ customer service - would buy again! ;-)

@snapey I can select text when the box is open (FF/Mac)

07 Nov
6 days ago

ohffs left a reply on All Problems With The New Laracasts Design

Just to chip in with my tuppence worth.... ;-) The new design looks great Jeffrey - congratulations! :-). It's like all the slick things I'd love to do in my own projects but never get the time - so I'm also a bit jealous ;-)

Problem-wise - the notification thing now appears on Firefox (yay) - but when you try and scroll down the list if you have a lot it scrolls the main page 'underneath' rather than the notifications themselves. Oh - and is there any way to clear the notifications list? I think I have quite a lot due to the old behaviour with FF.

Congratulations again - I'm off now to see how many other things I can make spin/expand/do-whizzy-stuff :-)

03 Nov
1 week ago

ohffs left a reply on How To Make A Multi Select Value Into Single String Using Javascript Or In Laravel?

In your controller I think you could just use implode :

$csvLocations = implode(',', $request->job_location);

ohffs left a reply on How To Generate A Unique But Simple Id For Ticket?

I tend to use hashids for this kind of thing.

30 Oct
2 weeks ago

ohffs left a reply on How Do You Handle Case Sensitivy Differences Between OSX And Forge?

By co-incidence - it's one of the nice side-effects to running your tests inside a Docker container. You can do it locally or via a service like Gitlab or various others. It's also nice to be able to match the OS/DB/etc from your server to catch other things like mysql/sqlite differences.

ohffs left a reply on Nested V-model

I've given in and just made model.property be accessed via a data() prop. Eg:

// before
v-bind="model.property"
...
data() {
  model: this.originalProp,
}

// after
v-bind="property"
...
data() {
  return {
    model: this.originalProp,
    property: this.originalProp.property,
  }
}

ohffs started a new conversation Nested V-model

'Allo,

I've got a child component where I do a v-bind="model.property" to pass it the data and get it back via an $emit('update', newValues). The data shows up as reactive in the vue devtools so it seems to be working as I'd expect.

But... the model.property is used in a validation method on the model and in there it doesn't seem to notice the updated values until you click onto another input and change it - then it 'notices' the change to the model.property. Which is kind of breaking the validation as it keeps seeing the model.property as invalid unless you happen to have edited another field afterwards.

I've tried all sorts of things to work around it - using a getter/setter computed property with a watcher, calling $forceUpdate, etc - but it all gets progressively more ugly - and still doesn't work.

Anyone else hit this and have a magic solution? :-)

28 Oct
2 weeks ago

ohffs left a reply on Removing Some Illuminate Packages From Laravel

You could try just commenting out the service provider entries you don't want in config/app.php? Then they won't be loaded when the framework boots up.

27 Oct
2 weeks ago

ohffs left a reply on Firefox And Laracasts.com/discuss

Hopefully (the old IT refrain) the new design that's coming will fix things for we poor Firefox users ;-). I know we're a minority - but I always feel a bit sad when a site aimed at web developers is basically saying 'just use chrome' :'-/

I did spot this video about the redesign on youtube though - which makes me think a) Jeffrey is quite thrilled with the new design and b) it's due Real Soon Now(tm) :-)

25 Oct
2 weeks ago

ohffs left a reply on Web VS API On A Project

I'm in the process (well, just started on it really) re-writing an old app and as I know in advance it will be consumed by other apps too (data sharing, some so I can lock down access etc) I've started going 'api first'. That way I'm dog-fooding my API as I build out the main 'meat and potatoes' part.

Usually I do 'web app first' with a bit of an API - but it can get a bit soul-destroying duplicating the work when you get another window onto the data from another app (sometimes it's even adding two separate API endpoints for the same thing as I'm a bit fast'n'loose with the internal one but the external needs to be a bit more locked down).

It's quite annoying in any case ;-) Loosing access to a lot of the nice comforts of a regular web application is quite frustrating :-/

21 Oct
3 weeks ago

ohffs left a reply on Will Node.js Replace PHP & Laravel?

People have always been saying that X is the future and Y is on the way out. Over the longer term (as in decades+) sometimes they are right but mostly things just carry on - some people will move to a different language stack, some will stay, some will arrive.

Whether it's 'rails is the future - php is doomed!' or 'node is the future - php is doomed!' or 'golang is the future - node is doomed!' - it all comes and goes. I think I lost track of number of times I'd heard that C was doomed sometime around 1985 and yet here we are all using tools written in it.

Use the tools and languages you like, the ones that make sense in the context you're working in - keep an eye on the landscape around you and experiment with new things sometimes. Will PHP be around in another decade? Probably. Will it be as popular & will Laravel still be around? Maybe.

20 Oct
3 weeks ago

ohffs left a reply on Guys How To Use Default Values User Model Laravel?

I think you'll want to run your password through bcrypt() - otherwise you will just be storing the plain text in your database which probably isn't what you want. So just do :

'password' => bcrypt($request->password)

and it will turn it into a long 'hash' string like "$2y$10$vTR4EBkuOmQxL/d7iKZQDO/HIQMRLfxtb0NTS6cZPTj6NMv0S3SW." which laravel will be able to match when the user logs in.

19 Oct
3 weeks ago

ohffs left a reply on Is To Build Own Image Nude Checker In Laravel

If you want to avoid any 3rd party services, your best bet is probably using something based off of OpenCV and run it via a queue worker. For instance this little python example : https://github.com/mrgloom/skin-detection-example . I don't think there's a lot of OpenCV stuff for PHP sadly. Or a more basic PHP (and very old) example https://github.com/FreebieStock/php-nudity-detector

But as @adelf said - it's quite complicated and there's a big, big difference distinguishing between an image with 'nudity' and an image with a lot of 'skin colour' (have fun deciding on what that is...)

ohffs left a reply on Guys How To Use Default Values User Model Laravel?

You could also do a straight merge on the request, something like :

User::create(
  array_merge(request(['email', 'mobile_number]), ['user_type' => 'job seeker', 'password' => bcrypt(request('password'))])
)

It might be nicer if you added a little method to your User model though - something like :

public static function createJobSeeker($attributes)
{
  $attributes['user_type'] = "job seeker";
  $attributes['password'] = bcrypt($attributes['password']);
  
  return static::create($attributes);
}

// then in your controller
$user = User::createJobSeeker(request(['email', 'mobile_number', 'password']);

ohffs left a reply on How Much Is A Mid-level Laravel Coder Worth Per Year?

The payscale website has quite a lot of figures for different countries & levels of experience that you can click through. The data seems to get pulled from job adverts so might even be vaguely accurate ;-)

ohffs started a new conversation Laravel Telescope

https://mattstauffer.com/blog/introducing-laravel-telescope/

Sounds like it might be quite useful. I've got a local on-prem install of sentry to track exceptions which I'll probably keep using as we're not just running laravel apps - but telescope looks like it'll be really handy for deeper insights into laravel stuff.

18 Oct
3 weeks ago

ohffs left a reply on Saving Array Of Data Inside Redis Database.

It kind of depends what you want to do with the data in redis. You could use a straight key->value, a hash, add it to a set, etc. Eg,

$key = "user:{$per->id}";
Redis::hmset($key, $per->toArray());
Redis::set($key, $per->toJson());
17 Oct
3 weeks ago

ohffs left a reply on Calculate Lines Of Code

I also use phploc for this kind of thing.

13 Oct
1 month ago

ohffs left a reply on Controller Method Visibility - Protected Vs. Public

Thanks @bobbybouwmann - but my understanding of PHP's visibility rules were that you couldn't call a protected method on a class directly? I realise you can inherit them in extended classed (as opposed to private ones). So for instance :

<?php

class Test
{
  public function publicMethod()
  {
    print "hello from public\n";
  }

  protected function protectedMethod()
  {
    print "hello from protected\n";
  }
}

(new Test)->publicMethod();
(new Test)->protectedMethod();

Running :

$ php test.php

hello from public
PHP Fatal error:  Uncaught Error: Call to protected method Test::protectedMethod() from context '' in test.php:17
Stack trace:
#0 {main}
  thrown in test.php on line 17

Which is what made me think that Laravel's is bypassing the protected visibility. I notice on the \Illuminate\Routing\Controller class there is :

    public function callAction($method, $parameters)
    {
        return call_user_func_array([$this, $method], $parameters);
    }

So it's possible it's doing something vaguely like :

// get('/show/{id}', '[email protected]');
[$routerName, $method] = explode('@', $routeDestination);
$router = new $routerName;
$router->callAction($method, ['id' => 1);

Which would allow calling the protected method. But still seems like something that we shouldn't really be able to do, I think... ;-)

12 Oct
1 month ago

ohffs started a new conversation Controller Method Visibility - Protected Vs. Public

I was just trying out the [https://infection.github.io/](Infection mutation testing] package for, well, something to do on a Friday afternoon ;-)

It threw up a lot of issues where it could change the visibility of a controller method from public to protected and still work. Which seemed a bit odd - so I tried it manually on a few index/store methods and it does look like laravel will happily direct a request to a method that is marked as 'protected'. I'm guessing it's some kind of reflection side-effect, but it seems a little... odd? 'private' methods don't work, but 'protected' work as if they were public.

Anyway - is this just me? It's now vaguely worrying me that I've typo'd 'protected' rather than 'public' in bits of code and it's just worked because I'm using the container rather than by design.

11 Oct
1 month ago

ohffs left a reply on Page Freezes When Redirected After Sending Big Task To The Background.

I've seen that happen when a lot of memory is being used - in fact just yesterday :-). That's what came to mind when I read your description :-)

ohffs left a reply on Page Freezes When Redirected After Sending Big Task To The Background.

Can you just dispatch the whole procedure as a background job rather than doing any work in the controller? So your controller store method would be more like :

public function store(CsvImportRequest $request)
{
    BulkImportUsers::dispatch($request->users-file, $request->master);
    return redirect()->back()->with('success', 'Your file is being processed');
}

You'd have to do something in the background like setting a redis flag so you could notify the user on completion/failure.

ohffs left a reply on What To Clear After Doing Git Pull On Server?

You could maybe use a 'git hook' to run the script - it's a long, long time since I used plesk so not 100% how it would tie in.

'Deployer' might work out easier for you - it will ssh into your server for you and run all the commands. It also gives you 'zero downtime' deployments and roll-back if things go wrong.

For your front-end - view:clear should cover most of it. Depending what you mean by 'front-end' and what you're doing.

ohffs left a reply on What To Clear After Doing Git Pull On Server?

The easiest way might be to write a little shell script like 'refresh-code.sh' in your repo. So instead of doing a git pull you'd run refresh-code.sh:

#!/bin/bash

set -e

git pull whatever-you-need
php artisan config:cache
php artisan view:clear
... etc

You could also look into a tool like deployer to take care of it for you.

06 Oct
1 month ago

ohffs left a reply on Is There Any Good Books For Designing Api (paid Or Free) ??

Phil Sturgeons book was a good read for me at least. Not specific to Laravel (even though he was a very active PHP person) - but the ideas are easily transferable.

ohffs left a reply on How To Log All Route Calling Into File?

The tutorial here is for laravel 4.x - but it might still work ok as a start for what you need.

ohffs left a reply on Redis For Caching And Sessions Both?

You can - just be a bit careful about doing something like Cache::flush(); as it will clear everything from redis, not just cache items (well, it used to - possibly it's been updated - but best check before it bites you like it did with me!) :-).

You might want to look into setting different config/database.php redis connections, one for cache and the default one for sessions - make one 'database' => 0 and the other 'database' => 1 - that way you should avoid any Cache::flush() type issues :-)

ohffs left a reply on What Are The Pros And Cons Of Laravel Disk File Sytem Over Tradional File System ?

You get a lot of flexibility without having to change your code. For instance, you can store a file on your local server, or a remote sftp site, or an AWS S3 bucket and still use the same kind of code, eg :

Storage::disk('avatars')->put('file.jpg', $contents);
Storage::disk('audio')->put('file.mp3', $contents);

If you needed to move your 'audio' disk from a local one to amazon S3 - it would be quite easy and your code wouldn't really change. Compare it to doing it by hand and you can see how it makes life easier :-)

05 Oct
1 month ago

ohffs left a reply on GDPR For Developers

@DirkZz the legal advice we've had is that anonymising the user is probably good enough. But no-one is quite sure yet - and I guess no-one wants to be the 'test case' ;-). I've taken the fairly simple steps for user accounts and just changed the username/email/etc to be 'ANON{$ID}' so that the user isn't identifiable as a 'person' any more, but I don't need to go through null'ing lots of data.

I'm not quite sure what to do in cases where the user has identified themselves though (like on here if I signed this post with my real name in the body of the post). My username would be anonymous - but my data would still be there. So I think having a fall-back of deleting (or at least emptying) all the data might be needed if users can do that kind of thing.

Keeping data around is, again from the advice I've had, is to keep it as long as you require for legitimate business purposes - but no longer. So if you need to keep it around for insurance, legal reasons - whatever - then you're fine. If you keep it around for 10 years just because you might want to send them a 'hey - we haven't heard from you in a while' marketing email - then that's not ok.

The 'prevent processing' is still my main issue. I have lots of reports, mailing list generators etc that scan the users table - which all have to become 'processing' aware now. Which isn't quite so bad if everything is in Laravel - but when I've got a python script that does something, a bit of Perl to mangle some DB->CSV stuff, storage allocation etc - then it become quite annoying to do. I've got some systems where the data is 'copied forward' each year (eg, duplicated but with a '2017/2018', '2018/2019' flag for the current year) - but if the user has asked that their data isn't processed - do I skip their record and all relations? I don't know - it would make the DB a bit of a mess if they then said it was now ok to process their data - coping it forward into a changed DB would be a royal pita :-/

04 Oct
1 month ago

ohffs left a reply on Thinking About Moving Away From Bootstrap, Thoughts?

I think a big advantage of bootstrap is that a lot of other libraries/plugins will generate bootstrap-friendly html. Regular bootstrap does look a bit 'familiar' I guess - but on the other hand it works very well and a lot of cross-browser edge-cases are taken care of for you. There are plenty of themes for it too if you want to mix it up a little without doing it all yourself.

I quite like bulma and again - there are a lot of ready-made themes to pick from. I find it a little less verbose than bootstrap. On the other hand it's still in development so you can find yourself having to re-do various bits of html when it bumps from version 0.x to 0.y.

I don't really like using a lot of ready-made vue components unless they are very generic - so things like vuetify make me quite wary of feeling a bit 'all or nothing' (I guess 'vendor lock in' in a way). But if you're ok with that then it's a pretty comprehensive offer :-)

I've used tailwind for some home projects and it's been really nice (especially in conjuction with vue) - but again it's still at 0.x and doesn't have the 100,000's of users that bootstrap etc have to check every browser issue.

If it's really just that you're a bit bored of the bootstrap default look - not something technical about it - then I'd be tempted to go that way myself just because it's the 'path of least resistance'. Last time I was using bootstrap and sat thinking 'oh no - it looks like a million other bootstrap sites!' then when I showed it to the users they were really, really impressed by how it looked - so maybe as dev's we're more fickle than regular users are ;-)

ohffs left a reply on GDPR For Developers

@Mick79 oops - clicked the correct answer button (again) instead of the thumbs up one :-). Have some points anyway :-).

GDPR-wise the really nasty bit for me is the 'restrict processing' part - the anonymisation/export stuff is all quite straightforward, but having to have a flag that prevents users being processed (or even seen) is a bit of a pain. I'm leaning towards some kind of global scope at the moment - but it's just kind of 'masking' the problems as everything needs to become 'restricted processing' aware :-/

03 Oct
1 month ago

ohffs left a reply on I Need Help How To Upload Image Correctly

I think the enctype="multipart/form-data" that you have on the input field should be on your <form> tag instead.

Other than that - I think you're trying to save the whole file upload in the database from a quick read of the code. Maybe try something like this just to get things going :

if ($request->hasFile('rent_proof')) {
  // store the uploaded file on disk and get the filename
  $file_path = $request->file('rent_proof')->store('proof_rent');

  // now update the database with the path
  Rent::findOrFail($request->id)->update([
    'proof_rent' => $file_path;
  ]);
}

ohffs left a reply on Laravel Framework Version 5.6.38 - Code Review Using Static Analysers.

Give larastan a try maybe? It understands more about laravel so might give you some more helpful pointers. It's more about assessing your own code rather than the framework imho though - unless you're metric about a framework/library is that 'it gets N-points via XYZ static analysis' I guess.

02 Oct
1 month ago

ohffs left a reply on Data Lost After Redis Server Restart

Have a look at the redis config file - usually under a section marked 'SNAPSHOTTING'. There should be some entries in there that control how often it will take a backup of the data itself. Something like :

save 900 1
save 300 10
save 60 10000

Also check the 'dbfilename' in there - it will default to dumping the backup in the directory you started redis from - so you might want to set that manually.

ohffs started a new conversation GDPR For Developers

Came across this while digging around for a more practical guide on how we can think about implementing code/procedures around the GDPR. Didn't want to bump one of the old threads, so just posting here in case anyone else finds it useful :-)

https://techblog.bozho.net/gdpr-practical-guide-developers/

29 Sep
1 month ago

ohffs left a reply on SQlite NOT Throwing Exceptions For Unknown Columns In Where Clause

Ah - sorry, I mis-read your question :-/ At a guess, it's using more eloquent/query-builder magic when not using 'whereRaw'. So possibly like doing an 'if ($model->non_existent_field === true)' won't give an error. But I'm guessing :-)

ohffs left a reply on How To Pass Additional Parameters To Resource Class?

You can over-ride the constructor on api resource collections - that might be what you're after?

ohffs left a reply on SQlite NOT Throwing Exceptions For Unknown Columns In Where Clause

Sqlite is very 'forgiving' - so it will let you do all sorts of things that other sql engines won't. So as you see you can query for things that aren't there. You can also do things like :

$table->integer('votes');
...
$model->votes = 'hello';
$model->save();

without raising an error.

ohffs left a reply on Is Bootstrap-multiselect Plugin Is Compatible With Bootstrap 4.1 ?

Have you looked on the issues page for the package? There's a question and answer for exactly what you're asking : https://github.com/davidstutz/bootstrap-multiselect/issues/1015

ohffs left a reply on Code Should Be More Efficient And Professional

Just to add to what @aurawindsurfing said above - for performance, you could always cache the results, so you'd do something like :

public function countTotal()
{
    $value = Cache::rememberForever("votecount:{$this->id}", function() {
        return $this->articlesVotesCount() + $this->commentsVotesCount();
    });
}

As long as you remember when adding/removing a vote by the user you call Cache::forget("votecount:{$user->id}"). You could also reduce the SQL overhead using aggregate methods on the query directly rather than fetching the results and sum'ing the column I think.

28 Sep
1 month ago

ohffs left a reply on Query Execution Test

I think you're maybe looking for transactions?

ohffs left a reply on Tailwind CSS

Adam Wathan (one of the folk behind tailwind) has some good practical videos on his youtube channel too : https://www.youtube.com/channel/UCy1H38XrN7hi7wHSClfXPqQ/videos

24 Sep
1 month ago

ohffs left a reply on Getting Involved

@Cronix I am now clicking that bookmarklet like a crazed person and going 'wooah!' ;-) thank you! :-D

ohffs left a reply on Notification Icon

Oh! Hurrah! :-D Thank you! :-D

23 Sep
1 month ago

ohffs left a reply on Getting Involved

It's often said - but contributing bug fixes and documentation to projects can be a great 'way in' and lets you get experience delving further into projects that you'd otherwise just 'consume'.

If there are any packages you use a lot - have a look at their github pages and check out the 'Issues' and see if there's anything that you could help with - or if you've used a package and spent time figuring out how some aspect worked that wasn't mentioned in the docs - try making a request to add some helpful docs.

Or even just write a blog post about 'how to do X with package Y' - some day someone will be looking for it on google and you'll save them hours of frustration :-) Same goes for replying to github issues - if you can post a reply for someone who is trying to figure out something you've already done you can help everyone in the future trying to do the same thing.

(I've actually found myself googling for a problem and found a reply I'd posted to github where I'd fixed the exact issue - just totally forgotten it - I buy myself a beer to thank myself ;-)

There's also Hacktoberfest coming up - which can be a really nice place to find projects that need help :-)

[And just to join in the somewhat OT complaints about the search - yeah, it is pretty difficult to use. Very slick visually, but quite hard to find anything of use. I've actually been using the forum way, way less since the last re-design due to the 'mentions' bug as the only way to see if I've had any replies/mentions is to go in manually and check the times on any questions - which is a bit annoying really. Hopefully the new redesign will fix some of this though :-)]

22 Sep
1 month ago

ohffs left a reply on API/Passport Series?

@Loach the search on the site only shows one course specifically about passport? And it seems to just be the regular oauth login flow rather than anything about running your own API with multiple types of consumer?

ohffs left a reply on Connected PlayStations

Maybe either give them fixed IP addresses and use a ping to check if they are online, or possibly make a call to arp -a to see what MAC addresses are showing up on your network. Then when an IP or MAC appears or goes away you can update your application.