rosswilson252

rosswilson252

Member Since 4 Years Ago

Macclesfield

Experience Points 37,415
Experience Level 8

2,585 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 370
Lessons
Completed
Best Reply Awards 20
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.

18 Jul
3 days ago

rosswilson252 left a reply on AmCharts4 With Laravel 5 And Webpack Install

I've just noticed I'm having this issue too.

03 Jul
2 weeks ago

rosswilson252 left a reply on Trying To Get Property Of Non-object

Should it be possible for a quotation to not have a user?

rosswilson252 left a reply on Creating Models With Controllers, Factories And Migrations

It's a perfectly fine way to do it. Is there anything you don't like about this approach?

rosswilson252 left a reply on Error 302

A 302 isn't an error it's a redirect.

400 and 500 codes are errors: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status

14 Jun
1 month ago

rosswilson252 left a reply on Updating Session After Login With Extra Values.

For this you could hook in to the LoginEvent.

Run:

php artisan make:listener AddToSessionAfterLogin

Then n your App\Providers\EventServiceProvider add the following to the $listen array:

\Illuminate\Auth\Events\Login::class => [
    \App\Listeners\AddToSessionAfterLogin::class,
],

Obviously, feel free to import these classes if you want.

Then in your AddToSessionAfterLogin class, which you've just created, you can add the necessary logic to the handle() method i.e.:

public function handle(Login $event)
{
    session(['hello' => 'world']);
}

FYI, you can access the authenticated user with $event->user.

rosswilson252 left a reply on How Can I Install Vuejs In Laravel 5.2 Version?

What have you tried so far? Are you using Mix, Elixir or something else to compile your assets?

16 Sep
1 year ago

rosswilson252 left a reply on Any Good Single Image Uploader?

I would suggest having a look at:

http://www.dropzonejs.com/ -- preview and upload

https://fengyuanchen.github.io/cropperjs/ -- getting the crop data

http://image.intervention.io/ -- cropping the image on the server

07 Feb
2 years ago

rosswilson252 left a reply on Eagear Loading Multiple Tables

You'll have to include the id's in your selects as well otherwise Eloquent won't know what to put where.

02 Jan
2 years ago

rosswilson252 left a reply on Need To Include Extra Css Styles Otherthan Master Layout

An alternative to @SaeedPrez would be to use stacks https://laravel.com/docs/5.3/blade#stacks.

This way you could do something like:

@push('css')
    <link rel="stylesheet" href="{{ asset('css/custom.css')">
@endpush
<head>
...
@stack('css')

</head>

The benefit to using stacks over sections is that you can add to them from different blade templates if you want/need to.

rosswilson252 left a reply on Git Bash

I'm not a windows user, however, I do have a couple of windows users on my team.

Using the GUI for your development isn't a bad idea if you prefer it, however, from my experience you're more likely to come across a LIVE environment where you have to use the command line to work with GIT (I'm not saying you will but there is the possibility). If this is going to be the case then it's definitely worth using GIT bash to at least get yourself familiar with using GIT with the command line. I personally find it much quicker to type my commands that clicking through a GUI.

If you're always going to be using windows and you know you'll always have the GUI then you probably don't need to at all but getting use to the various commands that GIT provides can only help you in the long run.

22 Nov
2 years ago

rosswilson252 left a reply on Query Builder - Return Only If Relationship Has None Of

You should be able to achieve what you're after by using something like:

public function jobsClosed()
{
    return $this->jobs()->whereHas('work_orders', function($q) {
        $q->whereIn('phase_code', ['X', 'Y', 'Z']);
    }, '<');
}

Notice the '<' as the 3rd argument for whereHas (by default this is '>='). This is basically saying get me jobs where which have no work_orders with phase_code X, Y, or Z.

Hope this helps!

16 Nov
2 years ago

rosswilson252 left a reply on NotFoundHttpException In RouteCollection.php Line 161:

I could be wrong but try changing:

Route::post('/Org', ... 

to

Route::post('/org', ... 

If this doesn't solve you're problem would you show what url is throwing this error?

21 Oct
2 years ago

rosswilson252 left a reply on How To Get Database Records Number Variations Over Time

The additional insert shouldn't be a problem at all.

As well, you can just create a job to record the changes and then call the job from the event if you want to go down that route. Just remember that it might not be that beneficial at this point as (if you're using DB for your jobs) you're going to be performing an insert anyway. That being said you shouldn't notice any performance issues and your DB should be able to easily handle this -- if it were to struggle you would probably notice it in other areas of your application well before.

If you're going to create generic activities tracker https://laracasts.com/lessons/build-an-activity-feed-in-laravel might be a good place to start (if you haven't already seen it). There are few places you might want to expand on it but it's definitely a good starting point.

rosswilson252 left a reply on How To Get Database Records Number Variations Over Time

You could add another table to the mix purely for the sake of reporting. It would mean that you would end up with some duplicated data but they serve a different purpose.

You could go about it a couple of different ways:

Leave the schema for you're interestables the same and pretty much duplicate that table but add a flag to say whether it was selected or deselected. This way you wouldn't have to change your applications current behaviour.

  1. (If you really don't want to have as much duplication)

Use SoftDeletes and create a one-2-many between interestables and (the recording table). You would either still use a flag or just calculate the changes on the fly (assuming you'd only be tracking selects and deselects).

Either way, you can then just use Eloquent's event system to automatically record the changes.

Hope this helps!

rosswilson252 left a reply on Laravel Create And Edit Form With Vue JS

Are you still going to be writing your forms in a blade file or using .vue files?

rosswilson252 left a reply on How To Get Foreign Key Table Content

DB is just used to perform normal SQL queries so the above is basically:

SELECT * FROM `enquiry` WHERE `result` = 2

If you want to get your customers data you would either have to use a join e.g.

$enq = DB::table('enquiry')->join('customer', 'enquiry.customer_id', '=', 'customer.,id')->where('result','=', 2)->get();

Or (what is a much better idea, IMO) use Eloquent. https://laravel.com/docs/5.3/eloquent and https://laravel.com/docs/5.3/eloquent-relationships

If you decide to use Eloquent then just be aware that by default table names are assumed to be plurals of the class name so if yours are singular you will have to define them in your classes using protected $table = '';

Hope this helps!

rosswilson252 left a reply on Cannot Load Resources From Public Folder

Try example.com/uploads/images/filename.png.

20 Oct
2 years ago

rosswilson252 left a reply on Custom Relationship Method In Model

Am i correct in saying that personOne can be friends with personTwo but personTwo doesn't have to be friends with personOne?

19 Oct
2 years ago

rosswilson252 left a reply on Argument Passed To <controller::function> Must Be An Instance Of <typeA>, <typeB> Given

As in 5.0?

Either way the first issue I see is that your newresponse route has 2 params, however, the method params only has $comment (not including $request).

Try changing

newresponse(Request $request, Comment $comment)

to:

newresponse(Request $request, Post $post, Comment $comment)

rosswilson252 left a reply on Laravel5.3 Register Console Command

Just to follow on from @bestmono's answer.

If you've used php artisan make:command this will create a class in your app/Console/Commands directory. To register this you should just need to add the class to the $commands array in your app/Console/Kernel.php class.

As far as I'm aware the routes/console.php file is for when you just want to create a quick commands in a closure (kind of like when you might use a closure for a route instead of referencing a method in a controller).

Hope this helps!

rosswilson252 left a reply on Argument Passed To <controller::function> Must Be An Instance Of <typeA>, <typeB> Given

Could you show the routes for the controller? Also, what version of Laravel are you using?

rosswilson252 left a reply on Where() Condition Using Eloquent

Deposit::where('passing', '<', \DB::raw('end_passing') )->get() should give you what you're after.

Hope this helps!

rosswilson252 left a reply on Redirect Issue In Traits

The best way to achieve what you're after is not to return the redirect from the trait but to throw a custom exception and then catch that in the app/Exceptions/Handler.php.

The link for the docs is: https://laravel.com/docs/5.3/errors#render-method

Hope this helps!

18 Oct
2 years ago

rosswilson252 left a reply on Custom Validation Rule With Auth Facade ?

If you're just creating 1 or 2 you can throw them in the boot() method in your AppServiceProvider.

If you're going to be creating a few of these and/or your AppServiceProvider is getting a little bloated then you could create a new provider and again just place it in the boot() method of that service provider.

Steps to creating a new service provider (if needed):

php artisan make:provider ValidationServiceProvider

then register the new provider in your config/app.php file:

'providers' => [
    ... // The providers that have already been registered

    App\Providers\ValidationServiceProvider::class,
]

and then just place your validation rules inside boot() method:

    public function boot()
    {
        Validator::extend('old_password', function ($field, $value, $parameters) {

            if (Hash::check($value, Auth::user()->password)) {

                return true;
            }

            return false;
        });
    }

Finally just import the facades you're going to use.

Hope this helps!

07 Oct
2 years ago

rosswilson252 left a reply on How To Pass JS Id Into Route

You can't mix php and javascript in this way as php is processed on the server and the javascript will be processed in the browser.

What you could do is add data-url="{{ route('calls.sub_calls.logs.update',$call->id,$subCall->id, $id) }}" ($id being the same as the id in data-id).

This way, in you javascript, you can do:

    var url = $(this).parent("td").data('url');
        var description = $(this).parent("td").prev("td").prev("td").text();
        var log_time = $(this).parent("td").prev("td").text();
       
        $("#edit-item").find("input[name='description']").val(description);
        $("#edit-item").find("textarea[name='log_time']").val(log_time);
        $("#edit-item").find("form").attr("action",url );

rosswilson252 left a reply on AJAX Form Validation Using Request

What version of Laravel are you using? Also, would you be able to add you code for the ajax request.

01 Oct
2 years ago

rosswilson252 left a reply on Laravel Subtracting 2 Columns And Showing The Results

Do you want to persist those changes in the database or just do the calculation for the user?

06 Sep
2 years ago

rosswilson252 left a reply on User -> Skills Relationships

@concept_core Do you have any other ideas for implementing this and if so what are they?

From the way you have explained it I would also go down the path of having a pivot table.

If a user can have many skills and skills can belong to many users then that would be the ideal case for a m2m relationship. You can easily add different flags to the table as @InaniELHoussain and @pmall have said which is (potentially) more adaptable for the future.

The main down side I see from having the users information directly tied to the skills table is that introducing redundancy and, as it stands, I can't see any benefit from this as it's just a simple join query to begin with.

I'm not a DB expert by any stretch, however, (unless I'm mistaken) it's good practice to only denormalise data when it needs to be...

rosswilson252 left a reply on 5.3 Listener To Update Model/database

If that's the code in your listener then $user is just going to be the event.

Assuming you have $user as a property in your event then it would be:

public function handle($event)
{
    $event->user->login_at = Carbon::now();
    $event->user->save();
}
15 Apr
3 years ago
26 Feb
3 years ago

rosswilson252 left a reply on Vue V-bind Style

The main reason you're having an issue is because of the '-' in min-height and the fact that 4em isn't wrapped in quotes. (Remember, here you're just passing a javascript object).

So, you can either just wrap min-height and 4em in '' :

<div class="progress-bar progress-bar-info progress-bar-striped active" :style="{ width: server.domains + '%', 'min-width': '4em' }">

or keep them separate

<div class="progress-bar progress-bar-info progress-bar-striped active" :style="{ width: server.domains + '%', }" style="min-width: 4em;">

Hope this helps!

17 Dec
3 years ago

rosswilson252 left a reply on Laracasts Integrated With PhantomJS And VueJS

Thanks again, @attrox .

As you said you had got it working I persisted with my efforts. It turns out that PhantomJs was having an issue with a custom function that actual browsers are ok with. I updated to PhantomJs2.0 and this solved the issue.

For anyone else who finds this, (currently) the default npm package for PhantomJs is only on version 1.9.* , the package I've just used is phantomjs2.

20 Nov
3 years ago

rosswilson252 left a reply on Laracasts Integrated With PhantomJS And VueJS

Thanks @attrox. I have tried using wait for element and also just wait (up to 10 seconds) and it wasn't having any of it.

As per your advice I've tried editing the windowSize but that didn't seem to do anything either.

I've just taken a snap after waiting 10 seconds and it looks like PhantomJS doesn't want to render anything from VueJS.

16 Nov
3 years ago

rosswilson252 started a new conversation Laracasts Integrated With PhantomJS And VueJS

Hey guys,

I've started using Laracast's integrated package for acceptance testing. It works absolutely fine, but it is fairly slow with firefox. To help speed the process up I've installed PhantomJS, but now my all my tests fail due to not being able to locate elements generated by Vue.

Has anyone else had an issue with this?

06 Oct
3 years ago

rosswilson252 left a reply on How To Catch Eloquent's Queries Before Execution

Eloquent has it's own built in events system http://laravel.com/docs/5.1/eloquent#events.

The example given in the documentation is for adding the listeners to a Service Class, however, you can also add them directly to your model if it makes more sense to you/for your application e.g.

class Post extends Model {

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

        static::creating(function($post)
        {
            $post->created_by = Auth::user()->id;
            $post->updated_by = Auth::user()->id;
        });

        static::updating(function($post)
        {
            $post->updated_by = Auth::user()->id;
        });
    }

}

Hope this helps!

29 Sep
3 years ago

rosswilson252 left a reply on Calculating Totals

@Istables The link to the image you have provided is returning a 401 so we can't see the example you have provided.

14 Sep
3 years ago

rosswilson252 left a reply on Models: Clean, Concise Updates.

To answer the question directly you can use the fill() method, but I feel there might be more to it than that as you said some of the field names don't correspond to the fields in the database.

Would you be able to provide an example of the "dirty" way of doing what you're wanting to do and hopefully we'd be able to provide a cleaner way of doing it.

13 Sep
3 years ago

rosswilson252 left a reply on Sort By Value Of Model Method

Are you paginating the or will it just be one big list?

If you are paginating the results, could you add a little more detail to you question i.e. the method that you're using to calculate the score and also the eloquent query you have so far.

11 Sep
3 years ago

rosswilson252 left a reply on Vue.js Find Element(s) By Model

Thanks, @veve286. I'm trying to not have declare multiple directives, but rather attached something dynamically.

I found the answer to what I was after though:

The current vue instance has a _directives object so it was just a case of

                for (var key in this._directives) {
                    var dir = this._directives[key];
                    if (dir.name == "model" && dir.expression == model) {
                        return dir.el;
                    }
                }

rosswilson252 left a reply on Vue.js Find Element(s) By Model

Sorry @bestmomo, I should have been more descriptive. I've updated my question :)

rosswilson252 started a new conversation Vue.js Find Element(s) By Model

Hey guys,

This probably isn't possible but does anyone know if/how you can get an element/elements by it's model name in vue.js .

09 Sep
3 years ago

rosswilson252 left a reply on [Lumen] Terminable Middleware - Handle() Gets Called, But Terminate Doesn't. Why?

Have you added the middleware to your bootstrap/app.php file?

rosswilson252 left a reply on Which Version Of Laravel?

The Laravel 5 Fundamentals is just using 5.0.

The tutorial is still very relevant to 5.1 but there are a few changes. that you can look at here: https://laracasts.com/series/whats-new-in-laravel-5-1

08 Sep
3 years ago

rosswilson252 left a reply on Permissions And Git

Git doesn't actually store the permissions which is why they won't persist.

One way to do it would be to use a hook or there are a few other solutions here: http://stackoverflow.com/questions/3207728/retaining-file-permissions-with-git

rosswilson252 left a reply on Poor Database Connection Efficiency

Can you show an example of your code including the query?

rosswilson252 left a reply on .htaccess Not Redirecting To Error Document

Are you trying this with the built in PHP server i.e. php artisan serve or is it on an apache server?

06 Sep
3 years ago

rosswilson252 left a reply on Form Select Using Eager Loading

It might be worth looking at something at something like https://github.com/etrepat/baum.

I've used this package in a couple of projects now and it makes dealing with nested sets fairly easy (for the most part).