RossUK

RossUK

Member Since 1 Year Ago

Experience Points 4,220
Experience Level 1

780 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 29
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

03 Sep
1 week ago

RossUK left a reply on Getting And Ensuring Artisan Command Is Always Running

Thanks I'll check this out. Just need to lookup how to use it :)

RossUK started a new conversation Getting And Ensuring Artisan Command Is Always Running

I am looking at using a project I found on github to monitor and react to events on a phone system. The project is /enniel/ami (it connect to asterisk based phone systems) using a socket and triggers events realtime.

There is a command

php artisan ami:listen

How do I make sure this is always running and only running once?

Many Thanks

08 Aug
1 month ago

RossUK left a reply on General Design Question - Quickly Getting Account Balance

thank you that is what I ended up doing 👍

25 Jul
1 month ago

RossUK started a new conversation General Design Question - Quickly Getting Account Balance

I have an API route where a customer can retrieve information from my app using an api key. Each api call generates a log of the transaction and uses one credit.

Because the api can be hit in quick succession I am not sure how to quickly determine the customers balance without doing a sum of the transactions every time.

Im just after a high level overview of any ideas on how to best approach this. I need to be able to stop if they exceed their balance this is why i need it each time.

Hope that makes sense

Thanks in advance

17 Jan
7 months ago

RossUK left a reply on Attach File On Contact Form

Or give me an overview of the process to achieve this, thanks

RossUK started a new conversation Attach File On Contact Form

Can any one give me quick and simple example of how to include a file attachment on a contact form please?

Here is my existing controller method

lass ContactController extends Controller
{
    public function store(Request $request) 
    {

        $this->validate($request, [
            'name' => 'required',
            'email' => 'required',
            'subject' => 'required',
            'phone' => 'required',
            'message' => 'required',
            // 'g-recaptcha-response' => 'required|recaptcha',
        ]);

    Mail::to(env('WEBEMAILRECIPIENT',''))->send(new ContactForm($request));
    Mail::to($request->email)->send(new ContactFormConfirmation($request));

    return redirect()->back()->with('message', 'form submitted');

    }
}
21 Oct
10 months ago

RossUK left a reply on Correct Use Statement For Composer Library

I get that thanks but in this case the class I'm using didn't have a namespace to start with?

RossUK left a reply on Correct Use Statement For Composer Library

Hi,

I got it working, thanks for your help

I think it was conflicting with the built-in laravel Slack notification class names. What I did was left it autoloading in composer.json as normal and added a namespace to the top of the third party library's source file in the vendor directory. I then added using statement using the newly created namespace.

use \SimonBackX\Slack;
use \SimonBackX\SlackMessage;
//require (base_path('vendor/simonbackx/slack-php-webhook/slack.php'));

I'm pretty sure this is bad practice so I would be interested to know the correct way of dealing with this particular scenario :) If anyone can shed any light?

RossUK left a reply on Correct Use Statement For Composer Library

Unfortunately the built in slack functionality won't allow me to add buttons

RossUK left a reply on Correct Use Statement For Composer Library

Thanks I thought maybe something like that however if I do the above I get

Symfony\Component\Debug\Exception\FatalErrorException: Cannot declare class Slack, because the name is already in use in file /Users/Ross/LabProjects/PBXBridge/vendor/simonbackx/slack-php-webhook/slack.php on line 30

But if I comment out the line it cannot find it

Could it be conflicting with some of the built in slack notification code?

I have even tried renaming the class inside

vendor/simonbackx/slack-php-webhook/slack.php

to MySlack but I then I get

Symfony\Component\Debug\Exception\FatalErrorException: Cannot declare class MySlack, because the name is already in use in file /Users/Ross/LabProjects/PBXBridge/vendor/simonbackx/slack-php-webhook/slack.php on line 30

RossUK left a reply on Correct Use Statement For Composer Library

Hi , Yes I went through this but getting the following error so guess I need to include it somewhere in my controller ?

Class App\Http\Controllers\Slack; not found in file 

RossUK started a new conversation Correct Use Statement For Composer Library

I am trying to use a third party composer library.

https://packagist.org/packages/simonbackx/slack-php-webhook

I have done the usual composer require. In the docs it doesn't show how to include the library in my Laravel project (Which use statements to use or app.php etc) . I know there is probably a way to work this out but I'm pretty new to Laravel and not sure what to do. Can anyone help please?

RossUK left a reply on Display Laravel Echo Pusher Event Values In Vue Component

great all good now thanks very much :)

16 Oct
10 months ago

RossUK left a reply on Realtime Progress Bar

Thanks again for this I managed to muddle through and get this working using Vue and Pusher. It was also my first experience of using Vue and adding realtime feedback so really pleased with the results.

14 Oct
11 months ago

RossUK started a new conversation Display Laravel Echo Pusher Event Values In Vue Component

I have been following the series

https://laracasts.com/series/get-real-with-laravel-echo

in the example Jeffery passes an array to the view component I have tried reading the docs but can't quite figure out how to update single values for example a label or text box. In this example the Msg value between the p tags.

here is my vue component

<template>
<div>
        <div class="callout callout">
                <p>{{ msg }}</p>
        </div>
</div>
</template>

<script>
     export default {},
     created() {
     window.Echo.channel('progressBar').listen('UpdateProgressData', {{ message }} => {
     msg = message;
     })
     }
</script>

And here is my event. I have see the event values in the chrome js console

public $progress;
    public $message;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct($progress, $message)
    {
         $this->progress = $progress;
         $this->message = $message;
    }

    
    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new Channel('progressBar');
    }
13 Oct
11 months ago

RossUK left a reply on Import CSV Files And Excel Using File Streamed From S3

Got it sorted using local storage thanks. Is it normal to have to prefix the path (in this case storage/app/) ?

here is what I ended up with

Controller Method:

public function store(Request $request)
    {

        if($request->hasFile('file')) 
        {
        $path = $request->file('file')->store('temp-files');
        ProcessUploadedCDRFile::dispatch($path);
        return back();
        } 
    }

and the job method

public function handle()
    {

       $results = Excel::load('storage/app/' . $this->path); 
       Storage::delete('storage/app/' . $this->path);

       // do something useful with results
    }

Thanks again

RossUK left a reply on Import CSV Files And Excel Using File Streamed From S3

Think I'm going to go with local storage as it's going to be deleted after use :)

Ill post back my solution once I have read how to store and delete off the local file system to a temp folder

RossUK left a reply on Import CSV Files And Excel Using File Streamed From S3

I think its because the PHPExcel_Reader is expecting a filename but I'm not sure how to sort it.

below extracted from error message

  public function canRead($pFilename)
    {
        // Check if file exists
        if (!file_exists($pFilename)) {
            throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
        }

RossUK left a reply on Import CSV Files And Excel Using File Streamed From S3

Thanks almost there something isn't quite right when I try this I get the following

Could not open /Users/Ross/Projects/TestCDRProcess/Id , Customer, Telephone Number,

Those are the file headers ?

RossUK left a reply on Import CSV Files And Excel Using File Streamed From S3

That's what I was thinking. I just need to work out the best way of managing the files so they are deleted after they are processed :)

Thanks for your help

RossUK left a reply on Import CSV Files And Excel Using File Streamed From S3

Actually I tried this and didn't have any luck I received the error

Serialization of 'Illuminate\Http\UploadedFile' is not allowed

I also tried to comment out the Serialization parts and received the same error

amespace App\Jobs;

use Illuminate\Bus\Queueable;
//use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

class ProcessUploadedCDRFile implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable;//, SerializesModels;

    protected $file;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($file)
    {
        $this->file = $file;
    }

RossUK started a new conversation Import CSV Files And Excel Using File Streamed From S3

I have a job to process large uploaded csv files. I want to process these as a queued job. Because the queued jobs can not accept a file as a passed in parameter I had the idea of uploading the file to S3 first then use the file from s3 in my csv processing job.

I have tried this using Maatwebsite/Laravel-Excel but it wont accept the streamed file from S3.

$contents = Storage::disk('s3')->get($filename);
        $results = Excel::load($contents);

So I can process the csv in the background can anyone recommend a better way of doing this or maybe a better csv, excel import library.

RossUK left a reply on Laravel Echo Not Listening/working On Pusher Channel Event

Found my error here I had a typo in my bootstrap.js method

    .listen('UpdateProgressData', e => {

changed to

  .listen('UpdateProgressData', (e) => {

RossUK started a new conversation Laravel Echo Not Listening/working On Pusher Channel Event

Hi I have been trying to use Laravel Echo with pusher after going through the tutorial on Laracasts. I am trying to listen on a public channel just as a test but cannot get a message to log to the console. The project I am trying to add this to is Laravel 5.5.

So far I have the following:

my .env file setup

an event called UpdateProgressData

<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class UpdateProgressData implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $foo;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct()
    {
         $this->foo = 'bar';
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new Channel('progressBar');
    }
}

and the following at the bottom of /resources/assets/js/bootstrap.js

import Echo from 'laravel-echo'

window.Pusher = require('pusher-js');

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: '8e30361e3c24c96c3397',
    cluster: 'eu',
    encrypted: true
});

window.Echo.channel('progressBar')
    .listen('UpdateProgressData', e => {
        console.log('UpdateProgressData has been updated!');
        console.log(e);
    });

I can see the connections in the pusher debug console and also the event data but nothing is being logged to the console.

I have probably missed something obvious if any can help me debug it will be much appreciated :)

10 Oct
11 months ago

RossUK left a reply on Realtime Progress Bar

Hey, this is really useful info thanks for taking the time to give me a head start very much appreciated! Going to go through the series first and then take it from there. :)

RossUK started a new conversation Realtime Progress Bar

Hi,

I have a large background task / queue task that I want to be able to give realtime progress on. I want to end up with something like this

https://blog.pusher.com/improve-user-experience-app-real-time-progress-bar-tutorial/

Does anyone have a good tutorial for something like this or can advise me on the front end part of it. Just a high level overview would be great :)

08 Oct
11 months ago

RossUK left a reply on Create Just One Related Model For Feature Test

Great, works perfectly thanks

RossUK started a new conversation Create Just One Related Model For Feature Test

If I am writing a test that contains both a user model and a post model each has an associated Model Factory. I know I can do the following to create a collection of related records but how do I create just one of each for use during a feature test.

$users = factory(App\User::class, 3)
           ->create()
           ->each(function ($u) {
                $u->posts()->save(factory(App\Post::class)->make());
            });

for example

$customer = factory('App\User')->create()

// then add a single post to this user

Many Thanks

05 Oct
11 months ago

RossUK left a reply on Setting The Existing Value On A Drop Down Box When Using Partial For Edit And Create Form Fields

Yes thank you very much. This is what I have now and works perfectly

//CustomerController.php

    public function create()
    {
        // pass blank customer (for select menu)
        $customer = new Customer;
        return view('customer.create',['customer' => $customer]);
    }

public function edit(Customer $customer)
    {
        $customer = Customer::find($customer->id);
        return view('customer.edit', ['customer' => $customer]);
    }

And in my customer/partials/formfields.blade.php

<select class="form-control" name="title">
      <option value="" @if(old('title', $customer->title) == "") selected @endif>Select</option>
      <option value="Mr." @if(old('title', $customer->title) == "Mr.") selected @endif>Mr.</option>
      <option value="Mrs." @if(old('title', $customer->title) == "Mrs.") selected @endif>Mrs.</option>
      <option value="Miss" @if(old('title', $customer->title) == "Miss") selected @endif>Miss</option>
      <option value="Ms." @if(old('title', $customer->title) == "Ms.") selected @endif}>Ms.</option>
      <option value="Dr." @if(old('title', $customer->title) == "Dr.") selected @endif>Dr.</option>
      <option value="Prof." @if(old('title', $customer->title) == "Prof.") selected @endif>Prof.</option>
    </select>

Thanks again :)

04 Oct
11 months ago

RossUK left a reply on Setting The Existing Value On A Drop Down Box When Using Partial For Edit And Create Form Fields

ok, now I have this. This gets the correct initial value on the edit form and retains the value on validation error. It does however still throw an Undefined variable: customer error when trying to create a customer :/ :)

<select class="form-control" name="title">
      <option value="" {{ (optional($customer->title) === "" or old('title') === "") ? "selected" : "" }}>Select</option>
      <option value="Mr." {{ (optional($customer->title) === "Mr." or old('title') === "Mr.") ? "selected" : "" }}>Mr.</option>
      <option value="Mrs." {{ (optional($customer->title) === "Mrs." or old('title') === "Mrs.") ? "selected" : "" }}>Mrs.</option>
      <option value="Miss" {{ (optional($customer->title) === "Miss" or old('title') === "Miss") ? "selected" : "" }}>Miss</option>
      <option value="Ms." {{ (optional($customer->title) === "Ms." or old('title') === "Ms.") ? "selected" : "" }}>Ms.</option>
      <option value="Dr." {{ (optional($customer->title) === "Dr." or old('title') === "Dr.") ? "selected" : "" }}>Dr.</option>
      <option value="Prof." {{ (optional($customer->title) === "Prof." or old('title') === "Prof.") ? "selected" : "" }}>Prof.</option>
    </select>

Thanks

RossUK left a reply on Setting The Existing Value On A Drop Down Box When Using Partial For Edit And Create Form Fields

No, afraid not. It retains the old value on validation errors etc but doesn't set the value on the page load. I'm curious if there are better ways to do the same thing as it seems a bit messy (my original method I mean)

RossUK left a reply on Setting The Existing Value On A Drop Down Box When Using Partial For Edit And Create Form Fields

this is what I have at the moment

 <select class="form-control" name="title">
                      <option value="" {{ old('title') === "" ? "selected" : "" }}>Select</option>
                      <option value="Mr." {{ old('title') === "Mr." ? "selected" : "" }}>Mr.</option>
                      <option value="Mrs." {{ old('title') === "Mrs." ? "selected" : "" }}>Mrs.</option>
                      <option value="Miss" {{ old('title') === "Miss." ? "selected" : "" }}>Miss</option>
                      <option value="Ms." {{ old('title') === "Ms." ? "selected" : "" }}>Ms.</option>
                      <option value="Dr." {{ old('title') === "Dr." ? "selected" : "" }}>Dr.</option>
                      <option value="Prof." {{ (old('title') or $customer->title) === "Prof." ? "selected" : "" }}>Prof.</option>
                  </select>

RossUK left a reply on Setting The Existing Value On A Drop Down Box When Using Partial For Edit And Create Form Fields

Thanks I tried that but not sure how to apply to a select menu please can you help?

RossUK started a new conversation Setting The Existing Value On A Drop Down Box When Using Partial For Edit And Create Form Fields

I am trying to reduce code duplication by having a partial for my create and edit customer form fields.

    <form action="/customer/{{$customer->id}}" method="POST" enctype="multipart/form-data">

                     {{ csrf_field() }}

             {!! method_field('patch') !!}


             @include('customer.partials.formfields')

            </form>
          </div>

I have a select menu for title eg. Mr. , Mrs. Miss etc Im not sure how to set the selected attribute in my edit and delete form for both old('title) and also $customer->title

I have done the below on the create form

<option value="Mr." {{ old('title') === "Mr." ? "selected" : "" }}>Mr.</option>

But not sure how to do this for edit and create?

RossUK left a reply on Struggling To Find Error In Test

Hi, thanks for this I have been looking at it too long. I'm still/always learning. Is there any way to spit out the error during the test? I get the assertion errors but not why the error 500 is thrown. I'm just curious the correct way of debugging

Thanks

RossUK started a new conversation Struggling To Find Error In Test

Hi I am getting an error 500 on a test I am running and am struggling to find what I have dome wrong. Below is my test and controller method and route :)

 /** @test */
    public function authenticated_users_can_update_existing_customer()
    {
        $this->withExceptionHandling();

        $customer = factory('App\Customer')->create();

        $data = [
        'company' => 'Acme Ltd',
        'first_name' => 'Ross',
        ];

        $this->actingAs($this->user)
        ->patchJson(route('customer.update', $customer->id),$data)
            ->assertStatus(202);

        $customer = $customer->fresh();

         $this->assertEquals('Acme Ltd', $customer->company);
    }

And my Controller Method and route

public function update(Customer $customer,Request $request)
    {
         //$this->validator(request()->all())->validate();

        $customer->update($data);

        return request()->wantsJson()
            ? response()->json($customer, 202)
            : null;
    }
// Resource Routes
    Route::resource('customer', 'CustomerController')->middleware('auth');

Thanks for any help in advance :)

02 Oct
11 months ago

RossUK left a reply on Localised Faker In Test - Laravel 5.5

I sorted this using the following, not sure if this the best way

$this->faker('en_GB')->phoneNumber;

RossUK left a reply on Realtime Frontend Blog Style Tag With Laravel

hey thanks looks interesting

RossUK started a new conversation Localised Faker In Test - Laravel 5.5

Please can someone help me to use an en_GB instance of faker within tests. I have tried reading the docs but can only find examples of using Faker in Factories and not using WithFaker in a test like below. Here is an example of where I would like to implement it :)

<?php

namespace Tests\Unit;

use App\User;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;

class LoginTest extends TestCase
{

    use WithFaker;

    /**
     * A basic test example.
     *
     * @return void
     */

    /** @test */
    public function test_example()
    {

        $user = User::create([
            'mob_no' => $faker-> mobileNumber(),
        ]);

    }

}
30 Sep
11 months ago

RossUK started a new conversation Realtime Frontend Blog Style Tag With Laravel

Hi,

Id like learn how to do some realtime stuff with Laravel. I think I probably need api routes and a JS framework but not sure where to start. In an existing Laravel App I have I need to add some billing tags to a report similar to blog tags in the style of this https://jsfiddle.net/dede89/f0b6gegt/ but with autocomplete for existing tags.

Can anyone point me at a good tutorial as a starting point.?

RossUK left a reply on Array Combine Totals

Hi,

Thanks. I think I was approaching this the wrong way I looped through the array instead to change the value

foreach($totals as $total)
       {
        $labels[] = $total['status'];
        $values[] = $total['count'];
        $colours = $this->chartColour($total['status']);
       }
29 Sep
11 months ago

RossUK started a new conversation Array Combine Totals

if I have an array like this [‘failed’ => 1, ‘completed’ =>5] pulled from a DB query but there are other options that may show up in the query that I need to include even if no results exist for example mple ```[‘failed’ => 1,‘completed’ => 5,‘busy?chieve this in php. Is there is a way to merge an empty array with one that has values or similar?

RossUK started a new conversation Laravel Eloquent GroupBy() And Get Count Of Each Group

if I have a table containing a job and a job can have a status of one of three values. What is the Laravel/Eloquent way of getting a count of each status?

I can do with separate count queries but not sure how to group-by and count with Eloquent.

RossUK left a reply on Problem With Eloquent Relationship

Ok Thanks again

RossUK left a reply on Problem With Eloquent Relationship

Thanks very much for your help I'll have a read through the docs. So without using eager loading would the job be lazy loaded by default? and do you know why I could access all the other job fields except for the name field without eager loading ?

Thanks again

RossUK left a reply on Problem With Eloquent Relationship

Hi, thanks

the second example works but the first one doesn't. Please can you explain your solution I don't understand why i would need "with" only on that particular column? :)

RossUK started a new conversation Problem With Eloquent Relationship

Hi, I have two models called CallLog and Job. CallLog belongs to Job.

class CallLog extends Model
{
     protected $table = 'call_log';

    public function job()
    {
        return $this->belongsTo(Job::class, 'job_id');
    }

Job includes the fields type,status,name

I am strugling to get the job name value

as a test if I run tinker and enter the following

$calllog = App\CallLog::find(5);
$job = $calllog->job;
$status = $job->status;
// I get the value I expect
=> "Completed"

however if I do the same with name eg. I get null

$calllog = App\CallLog::find(5);
$job = $calllog->job;
$name = $job->name;
// I get null
=> "null"

When I find the job I can see the name value set?

>>> $job = $calllog->job;
=> App\Job {#2937
     id: 4,
     created_at: "2018-09-12 21:12:25",
     updated_at: "2018-09-12 21:48:15",
     name: "test9",
     status: "Sent",
   }

Is there a problem using the field name "name"? If i temporarily change the field name to name2 it works fine. Everything else that uses this table field name works fine which is why I am confused. Although this is the first time I have used this field name in a relationship :)