diaglyph

diaglyph

Member Since 3 Years Ago

Sydney

Experience Points 8,480
Experience Level 2

1,520 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 60
Lessons
Completed
Best Reply Awards 2
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.

14 Feb
3 months ago

diaglyph left a reply on Polymorphic - Results Table For Skills And Category/Criteria

Thanks. I just wanted to check and see if maybe there was a way haha And in any case, the design has changed (again! lol) and has simplified the category/criteria relationship. So its all good now

13 Feb
3 months ago

diaglyph started a new conversation Polymorphic - Results Table For Skills And Category/Criteria

I'm thinking of using polymorphic relationship to store results (from different users) for skills and criteria in an assessment site. Skills are just a list of skills where the user will select a grade for each skill (would work very simply with the polymorphic relationship, and I have no problem setting that one up).

For the criteria, there is an extra level: they are grouped by Category (so there is a category_criteria table that links multiple criteria with categories) eg Documentation category could have Documentation writing criteria, Organisation criteria, etc and then Organisation criteria could also be used again within a different category (this is something that can be set up by the admin, to create these category/criteria pairings).

table: category
   id
   name

table: criteria
   id
   name

table: category_criteria
   id
   category_id
   criteria_id

So a result value would actually be related to a pairing from the category_criteria table. Is this doable with a polymorphic relationship? Or am I better off just having a separate results table just for the category/criteria pairings?

06 Feb
3 months ago

diaglyph left a reply on Lumen And Filesystem - Driver [] Is Not Supported

Ok disregard this, just my silliness in misnaming a disk

04 Feb
3 months ago

diaglyph left a reply on Lumen And Filesystem - Driver [] Is Not Supported

What do you mean by that? What do I have to do? I can't seem to find anything about this

diaglyph started a new conversation Lumen And Filesystem - Driver [] Is Not Supported

I'm using Lumen to make an API and I need to read/write files within the Storage folder. I've set up special "disks" for this purpose. I have a results folder linked to the "results" disk etc (within the config). If I do a simple \Storage::disk('results')->get('filename.csv') it gives me the Driver [] is not supported error

12 Jul
10 months ago

diaglyph left a reply on Using Pusher For WebRTC Video Call

Sadly no, couldn't work out any of it and moved to a commercial package for a while which provided all the stuff I needed at the time, but now that's been abandoned too.

13 Nov
1 year ago

diaglyph started a new conversation AuthenticationException Doesn't Trigger Unauthenticated

I'm using rappasoft/laravel-5-boilerplate.

Have a weird issue where I'm using the 'auth' middleware for routes. Testing access to a page that requires login. When not logged in it displays the Unauthenticated exception error, and does not redirect to Login screen. In the Handler.php file unauthenticated exists and has code to redirect to the login screen, but this function is never called!

Why would the unauthenticated function not be called on the AuthenticationException?? It does't make sense.

14 Jun
1 year ago

diaglyph started a new conversation External Addon Accessing Laravel App, Getting Spammy Errors In Log

I'm using an external system that is part of my laravel app. I've been able to give access to Laravel by doing:


$kernel = $app->make(Kernel::class);
$lresponse = $kernel->handle(Illuminate\Http\Request::capture());

With the appropriate includes above. This works fine. But I'm finding the log file is getting spammed with CSRF mismatch exceptions, pinpointing the line above -- $kernel->handle(Illuminate\Http\Request::capture())

I've put in the particular URI relating to this other system within the Verify CSRF exclude array, but looks like that is not getting picked up/checked.

Is there a way to make sure this particular URI is not checked at all to stop the exception spamming?

16 Apr
2 years ago

diaglyph left a reply on Detect When File Uploaded To A Folder In "public"

@antic

in config/filesystems, I set up a 'disk':

 'mylocation' => [
            'driver' => 'local',
            'root' => public_path(). '/uploads/folder1/folder2'
        ],

Then I get a list of files from the location:

$file_list   = Storage::disk('mylocation')->listContents();

I do this as a console command which I schedule to run at midnight eg ``php $schedule->command('findfiles') ->withoutOverlapping() ->daily() ->sendOutputTo($resultslogfile);

This will then get a list of files at the location and send to my event listener which will then process the files as needed eg
```php
                    event(new NewFilesEvent($file_list));

This works nicely for my needs.

27 Mar
2 years ago

diaglyph left a reply on Using League's SFTP Adapter With Flysystem

I guess there seems to be an issue with this "plugin", so I've removed it and tried "idct/sftp-client" instead, which works without any problems and fairly easy to use.

23 Mar
2 years ago

diaglyph started a new conversation Using League's SFTP Adapter With Flysystem

I've installed league's SFTP adapter for Flysystem.

I need to SFTP to a server to grab a file. Doing a test I can connect successfully, but when I call listContents() it returns null. For testing, I let it default to the user's home directory and it does contain files, so I should be getting files listed. Why would it return null?

Here is my test code. I've created a dummy function that I can run in tinker: (hiding IP, user and password for obvious reasons)

 $adapter = new SftpAdapter([
                                       'host' => 'xxx.xxx.xxx.xxx',
                                       'port' => 22,
                                       'username' => 'validuser',
                                       'password' => 'validpassword',
                                       'timeout' => 10,
                                   ]);

        $filesystem = new Filesystem($adapter);
        $adapter->connect();
        if ($adapter->isConnected())
            echo "connected\r\n";
        $ls = $filesystem->listContents('Desktop');

The user folder has a folder called Desktop, which has a couple of files. So when listContents() is called, it should be showing these files. It returns null instead.

08 Mar
2 years ago

diaglyph left a reply on Soap Tutorials And Queries

I came across a rather marvelous bit of php code! It's become a life saver! https://github.com/WsdlToPhp/PackageGenerator

A command line tool that will convert the WSDL into appropriate php classes and can also package into a composer compatible package! So then it's easy to install into the Laravel project. I highly recommend this tool for anyone needing to use Soap.

03 Mar
2 years ago

diaglyph left a reply on Soap Tutorials And Queries

That's what I'm trying to do. I have a SoapUI project file where it does a basic call to test the system. I'm trying to recreate that with PHP. But I'm stuck on how to specify the username and password as defined in the header.

diaglyph started a new conversation Soap Tutorials And Queries

Just wondering if there are any Soap tutorials? I can't seem to find anything that can help guide me.

Unfortunately I have no other option but to use a Soap client to send a request to a Soap service (external financial api service).

I've been looking at artisaninweb/laravel-soap but I don't quite understand how I am supposed to to make a successful call to the Soap service. How do I set up custom username and password fields? How do I actually send data through the service?

All I'm finding are code snippets out of context and it's just making it frustrating trying to find some sort of tutorial to guide me through.

Just for example sake, here is the header definition from the WSDL. How do I pass in the username and password as defined in this XML block using artisaninweb/laravel-soap

<xsd:schema elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://siebel.com/webservices" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <xsd:element name="UsernameToken" type="xsd:string" /> 
      <xsd:element name="PasswordText" type="xsd:string" /> 
      <xsd:element name="SessionType" type="xsd:string" /> 
    </xsd:schema>

Are there better soap clients that can be used in conjunction with Laravel?

30 Jan
2 years ago

diaglyph left a reply on How To Use Model Inside A Artisan Created Command?

$records` could be getting set to null. Dodump($records);``` before the foreach to see if data is getting returned

08 Dec
2 years ago

diaglyph left a reply on Dumping A Result Shows Values, Assigning To A Variable Becomes Null

ughhh don't worry, it was stupid typo on my part, missing 1 letter in the assignment and no way to delete this post haha

diaglyph started a new conversation Dumping A Result Shows Values, Assigning To A Variable Becomes Null

I have a helper function that returns a URL along with a title to display in a modal box, and when the user clicks Yes, it takes them to that URL. If I dump the result, which is an associative array (eg ['activity_url'=>'http://somewhere','activity_title'=>'Some title']) the dump displays the result properly, as expected. If I then go: $activityurl = $results['activity_url']; $activityurl returns NULL!

What would this happen?

28 Nov
2 years ago

diaglyph left a reply on Eloquent Many To Many Queries Returning Empty Or Incorrect. Why? Laravel 5.3

With regards to naming conventions etc it's always a good idea to do that from the beginning, rather than later, as you might introduce new bugs. I think changing the names as soon as you can would be a good thing, as it will help to read your code easier (especially for yourself, if for example, you have to come back to this code months later for some reason).

I'm thinking you might need to show how you've defined the pivot tables (can show the migrations or table definitions).

17 Nov
2 years ago

diaglyph left a reply on Ajax Post Request Causes 500 Internal Server Error

You should have something like: $.ajaxSetup({ headers: { 'csrftoken' : '{{ csrf_token() }}' } });

15 Nov
2 years ago

diaglyph left a reply on Laracasts Refresh

And as was suggested, a dark/night option would be fantastic!

diaglyph left a reply on Laracasts Refresh

Very clean look, well done :)

16 Oct
2 years ago

diaglyph left a reply on What Do I Need To Know Before I Even Think About Watching The "Laravel From Scratch" Series?

Also as they say, admitting you know nothing is the first step to learning ;)

diaglyph left a reply on What Do I Need To Know Before I Even Think About Watching The "Laravel From Scratch" Series?

On Windows, I'd highly recommend installing Homestead. It's what I use. Also make sure you have git installed for Windows, as it gives you the bash command prompt. Then when you "login" to Homestead, pretty much any command line stuff shown in the videos will work as expected.

26 Sep
2 years ago

diaglyph started a new conversation Route Used For API Returns Error 500 In Chrome But Works In Firefox

Very strange issue. A particular route I have set up for a simple API function returns error 500 in Chrome, but works as expected in Firefox. If I clear Cache in Chrome, it then starts working. Why would this happen?

21 Sep
2 years ago

diaglyph left a reply on How To Validate Date With Only Year Input

Perhaps you want to validate a range of years? eg 'min:1900|max:2500|size:4' You need to specify what a "valid" year is for your purpose

18 Sep
2 years ago

diaglyph left a reply on Running Into Windows 10 Vagrant Homestead Laravel Issues (mainly From The .yaml And Displaying In The Browser)

I followed these instructions: https://laravelista.com/series/laravel-on-windows/part/2

This helped me get set up and running. Also whenever you edit the yaml file to add new projects, I found using the space bar to space out each line works, don't use TABs.

You mentioned you have Homestead on your desktop? It should be in your user home directory. In the yaml file you can specify your project location to be anywhere on your computer. Also keep in mind the slashes for folders! eg

folders:
    - map: c:/projects/mylaravelproject
      to: /home/vagrant/laravel

sites:
    - map: laravel.app
      to: /home/vagrant/laravel/public

If you notice for folders I use / not \

diaglyph left a reply on Running Into Windows 10 Vagrant Homestead Laravel Issues (mainly From The .yaml And Displaying In The Browser)

One of the things you will need to do is install the Vagrant hosts updater plugin for windows. vagrant plugin install vagrant-hostsupdater This will make sure your hosts file in Windows is updated whenever you run vagrant up.

14 Sep
2 years ago

diaglyph started a new conversation While Seeding, Is There A Way To Stop The Scheduler?

I was just wondering, is there a way to temporarily stop the scheduler while seeding?

Or alternatively, is there a way to check if seeding is currently happening and for the scheduled tasks to not happen if they detect seeding?

26 Aug
2 years ago

diaglyph left a reply on Laravel Ajax

Did you want to do something like this?

Remove the href, make it '#' or 'javascript:void(0);' Then inside your on click event:

$.ajax({
url: '{{ route('jobs.changeMyJobStatus',array($job->id,'disabled')) }}',
data: {
job_id: '{{$job->id}}'
},
type: 'POST',
success: function(result) {
// do something with result
}
});

diaglyph left a reply on Problems With Blade In Laravel 5.3

I believe blade commands must be one line.

@foreach([1,2,3,4,5] as $item)
<do html >{{$item}}</do>
@endforeach 
25 Aug
2 years ago

diaglyph left a reply on Integrating CometChat With Laravel 5.1

Hi Mike

If you add: include_once(dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'); into the top part where you include the laravel bootstrap files it gives you access to the various components, so instead the giants blocks of code, you can simplify a lot of your code then eg instead of your giant block getting the user id, you can just reference the appropriate Laravel class (like Auth or Sentinel or whichever authentication system is used) to get the user id, making it just one line. The same goes for your SQL queries, a lot of that can be simplified using the Laravel QueryBuilder. Why aren't you guys taking advantage of these Laravel features??

22 Aug
2 years ago

diaglyph left a reply on Integrating CometChat With Laravel 5.1

Ok I think I have worked it out. The following code gives me access to the existing Laravel app and I am able to access Session and event Sentinel. But not sure what I would have to do to have eloquent access to models.

In a function I have:

 require '../../bootstrap/autoload.php';
    require '../../bootstrap/app.php';

    $app->make('Illuminate\Contracts\Http\Kernel')->handle(Illuminate\Http\Request::capture());
    
    $id = $app['encrypter']->decrypt($_COOKIE[$app['config']['session.cookie']]);
    $app['session']->driver()->setId($id);
    $app['session']->driver()->start();

    return $app;

This returns the current running Laravel, and I am then able to do something like $app['session']->get('dataname')

21 Aug
2 years ago

diaglyph left a reply on Integrating CometChat With Laravel 5.1

Unfortunately I can't switch out CometChat. So I was just wondering how I could make laravel usable within the cometchat stuff. CometChat sits in the public folder and loosely integrates but looking at various php system variables to see where Laravel is hooked in.

I want to be able to access Laravel from within their integration.

diaglyph started a new conversation Integrating CometChat With Laravel 5.1

I'm integrating CometChat with Laravel 5.1 at the moment. So far I've been able to get it loading up and using the existing users set up in the system. The integration from CometChat side is not the best! It seems like a hack job, not proper integration using the proper classes and packages, which makes their integration process a little painful.

What I would like to do is provide access to the running Laravel app instance within the integration.php file so that I can access sessions and even Sentinel (I am using Sentinel for the user auth). What's the best way to do? I've noticed in their integration.php file they get the app() instance but just to check the version number. I'm not quite savvy with the app() stuff to work out how I can use it to gain access to the rest of the system.

18 Jul
2 years ago

diaglyph left a reply on Using Pusher For WebRTC Video Call

Posting in the github repository of SimpleWebRTC the poster suggested I listen to the various events. I kinda tried that but I think I've just confused myself even more now. Exactly which events should I be listening to with regards to SimpleWebRTC and how should they be put through Pusher?

13 Jul
2 years ago

diaglyph left a reply on Using Pusher For WebRTC Video Call

I've come across the SimpleWebRTC package. It allows you to create your own connection to be used for signalling, so I wrote this:

var myConnection = {
  pusher: new Pusher('mypusherkey', { cluster: 'ap1' } ),
  channel: null, 

    on: function (event, callback) { 
        this.pusher.bind (event, callback); 
        console.log('ON EVENT ',event, 'CALLBACK ',callback); 
    },
    emit: function () { 
        if (arguments.length == 1) {
            if (arguments[0] === "join") {
                this.channel = this.pusher.subscribe("video-rtc-chat");
            } 
        }
        else 
            this.channel.trigger(arguments); 
        console.log('TRIGGER EVENT ',event, 'DATA ',data, 'CALLBACK ',callback);
    },
    getSessionId: function() { c
        console.log('SOCKET ID ',this.pusher.connection.socket_id);
        return this.pusher.connection.socket_id;  
    },
    disconnect: function() { 
        this.pusher.disconnect(); 
    }
};

Then in the code that initialises SimpleWebRTC I have

var webrtc = new SimpleWebRTC({
  localVideoEl: 'localVideo',
  remoteVideosEl: 'remotesVideos',
  autoRequestMedia: true,
  debug: true,
  connection: myConnection
});

webrtc.on('readyToCall', function () {
    console.log('ready to join');
  // you can name it anything
  webrtc.joinRoom('test-video-chat');
});

But I still can't get it to work with the remote stream, that is, nothing comes back. Looking in the dev console, I can see the events getting hooked up, but nothing actually starts.

diaglyph started a new conversation Using Pusher For WebRTC Video Call

I've been following this tutorial: https://medium.com/carbon-five/webrtc-made-simple-3bdbb1d8af8b#.g3ggsqvf6 off the Pusher website. I can't seem to get the video streaming to work. I'm getting an ICE error so the stream doesn't connect properly.

Just wondering if anyone else has been able to get WebRTC using Pusher working? Would like to see some pointers.

23 Jun
2 years ago

diaglyph started a new conversation Pusher - Subscribing To All User Channels On Initial Login

I'm using Pusher to put in chat capability into the app. What I'd like to do is subscribe the user to all their chat related private channels on login ie the first time they log in to the system. I'm using vinkla's pusher package and Pusher's JS library. I'm still learning Pusher so perhaps I've missed something, but I can see that the PHP library does not have a subscribe function (otherwise I would've easily hooked into the login event within Laravel). It seems like I can only subscribe using the JS library. How can I make sure the channel subscription only happens once on login and not each time they reload or visit a different page?

19 Jun
2 years ago

diaglyph left a reply on Using Blade @if , @elseif Directives - Some Advice Needed

So something like this?

    @if(type == 1)
        Menu Type 1
    @elseif(type == 2)
        Menu Type 2
    @elseif(type == 3)
        Menu Type 3
    @endif
01 Jun
2 years ago

diaglyph left a reply on Events Are No Longer Firing

Ok a colleague just discovered that I put ShouldQueue. So it's all good. Next time I should take notice of that haha

diaglyph started a new conversation Events Are No Longer Firing

A month or so ago I coded some stuff that listens to an event to process some files. It now longer fires at all. I've tried out multiple things: composer dump-autoload, composer update, etc It is simply no longer "listening" to my events. eg: So basically in my command, once a file is (or a number of files are) detected, it fires my event:

event (new CBSFilesDetected($files_times, $this->cbs_path));

In my service provider I have:

 protected $listen = [
        'App\Events\CBSFilesDetected'  => [
            'App\Listeners\ProcessCBSFiles',
        ],

I have no idea why the events would suddenly stop working??

29 May
2 years ago

diaglyph left a reply on $variable Is Null But Has Data When You Use Dump($variable)

Ok this can be ignored haha So I do a rest api call which just so happens to return a json object that is called user, and this reference is what is causing the issue. I was just getting it confused with the other user.

diaglyph left a reply on $variable Is Null But Has Data When You Use Dump($variable)

I've updated the OP with the code used in the loop

diaglyph left a reply on $variable Is Null But Has Data When You Use Dump($variable)

Strangely I got it working by getting the fields I wanted into separate variable, eg

$name=$user->name;
$id=$user->id;
etc

Doing this as the first part of the loop seems to stop the problem. All very strange.

diaglyph left a reply on $variable Is Null But Has Data When You Use Dump($variable)

I'm just wondering what could cause a variable to just suddenly become null when there are no assignments being made in the loop?

diaglyph started a new conversation $variable Is Null But Has Data When You Use Dump($variable)

Here's something very weird I have encountered and don't understand how this can happen. I have a function that creates a separate online login for existing users in my system (its a form of external integration). So I use a simple foreach for all the users in the system. eg

foreach ($users as $user) {

At some point half way through the first iteration, an error comes up "Undefined property stdClass $user". Why would $user become undefined half way through?? It makes no sense. I don't do anything with $user except get the name and some other fields, that's it. The $user object is only used to get field data, no changes are made to it. Here's the strange thing, doing dump($user) works fine, but $user still becomes undefined. I've seen this happen elsewhere too, where an array was created with items. Doing a dump of the array displayed the contents, but after returning the array, it returned a null instead of the contents.

13 May
3 years ago

diaglyph started a new conversation Relationship - A Way To Return The Opposite (something Like Set Difference)

I have a Participant (all participants are a User in the system, ie User -> Participant, and a User can have multiple Participant records) that can be in multiple Trials. I have a relationship set up in Trials that will return all the Participants that are linked to the trial. Is there a way to set up a relationship that can return Users who are not in that specific trial? e.g User A is in Trial B as a Participant, but not Trial C. If I go TrialB->participants, User A will appear in this list. If I go TrialC->participants, he will not appear. Can I make something like TrialC->notyetparticipant, in which Participant A's User record will appear? The reason I'm asking is for the app I'm working on, there will be around 18k users in the system. Currently doing tests with just 10k users and finding it eats up memory quickly because it does 10k queries (or close to). Would like to find a way to minimise the number of queries it needs to do.