speedydan

speedydan

Member Since 5 Years Ago

Experience Points
10,500
Total
Experience

4,500 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
128
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.

Level 3
10,500 XP
Sep
09
1 month ago
Activity icon

Started a new conversation Set Form Action Based On A Previous Selection

Hey!

I have a calendar vue component in Laravel and I need to be able to set a form action dynamically - based on what a user selects...

so - I have a select input (outside the form) that a user would select a site from:

<select name="sites" id="sites" class="tw-border tw-border-grey-400 tw-p-1 tw-rounded tw-block" v-model="siteInput" @change="updateCalendar">
    <option value="">Please select a site...</option>
    <option v-for="site in sites" :value="site.id">{{ site.name }}</option>
</select>

Once they've done this, it updates a calendar - and they can select the day they wish to book.

On the booking form that pops up, I need to submit it through to a specific url - based on the site id they have selected above...

for example:

<form action="/sites/1/visits/create" method="get">

Vue is quite new to me, so I'm at a bit of a loss on how to achieve this. Apologies if I've not posted enough info - happy to clarify where needed, but this is it in a nutshell!

Aug
11
2 months ago
Activity icon

Replied to Using RegEx Validation Rule

Hey @cronix - I have a textarea on a form, a bio basically - but I don't want users to be able to include any anchor tags with links in.

Activity icon

Started a new conversation Using RegEx Validation Rule

This might be a really silly question...

But I have the following regular expression that highlights any url in a block of text:

/(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$])/igm

And i'm wondering how I'd use this as a validation rule - the ending /igm seems to be causing issues - but I need them as part of the rule.

Jun
26
3 months ago
Activity icon

Replied to Regex To Test If Text Contains A URL

These are perfect - thanks!

Activity icon

Started a new conversation Regex To Test If Text Contains A URL

Hey,

I have a text field that I'm trying to validate where users should not be able to paste in URL's. I kinda had the regex rule working for this, but it was failing when someone added any words that included com - like company for example.

Is anyone able to help me out here? :-)

Apr
02
6 months ago
Activity icon

Started a new conversation Nova Subdirectory Install

I've installed Laravel in a subdirectory which seems to be working.

/var/www/laravel -- main laravel directory /var/www/html/hub -- public directory

My problem is that Nova isn't loading any assets, and just appears broken.

How can I go about making it work with the above setup?

Apr
01
6 months ago
Activity icon

Started a new conversation Installing Laravel In A Subdirectory - Images Not Showing

I need to install Laravel in a subfolder of an existing site.

I've followed this article: https://laravel-news.com/subfolder-install

and basically put the content of public in my subfolder, then updated the 2 paths in index.php to point to the main Laravel folder which is up a level.

The issue I have is that none of the images from local storage are being found, and images like the logo can't be found either, they just return a 404.

not really too sure what else to try?

Mar
25
6 months ago
Activity icon

Replied to Model Policy Impacting Nova Edit Functionality

I saw that Nova actually has functionality for this, just include the below in the Nova resource

public static function authorizable()
{
    return false;
}
Mar
24
6 months ago
Activity icon

Started a new conversation Model Policy Impacting Nova Edit Functionality

I have an Eloquent model called Listing, I've created a policy to ensure only listing owners can edit their own listings.

/**
     * Only a listing owner can amend it
     *
     * @param User $user
     * @param Listing $listing
     * @return bool
     */
    public function update(User $user, Listing $listing)
    {
        return $user->is($listing->user);
    }

Trouble is - this is stopping an admin user being able to edit listings from within Nova. What would be the best way around this to ensure Nova users can amend all listings?

Mar
22
6 months ago
Activity icon

Started a new conversation Form - Show Old Array Data And Existing Model Data

Hey,

I have a form I'm using for editing a listing.

It includes a section allowing a user to add multiple highlights. This is just a text field that duplicates each time a user clicks 'add another highlight'.

My question is - how do I show the old data for these fields, along with any features a user has already added.

so far I have this:

// Show existing highlights
@if($listing->highlights->count())
    @foreach($listing->highlights as $highlight)
         <input type="text" placeholder="e.g. One-to-one tutorials" name="highlights[]" class="highlight form__input mb-3" value="{{ $highlight->highlight }}">
    @endforeach
@endif

@if(is_array(old('highlights')))
    @foreach(old('highlights') as $highlight)
        <input type="text" placeholder="e.g. One-to-one tutorials" name="highlights[]" class="highlight form__input mb-3" value="{{ $highlight }}">
    @endforeach
@endif

This mostly works - but as I also need to show old data (in case there are any validation errors) - the old data is just duplicating the existing features.

can anyone point me in the right direction?

Thanks! :-)

Mar
17
7 months ago
Activity icon

Started a new conversation Eloquent - Show Only 'live' Results

Hi,

I have a listing model, and each record in the database has a 'live' column.

I'm wondering what the best way to grab all live listings when using Listing::all() - I don't want to have to do Listing::where('live', true) each time, so wondering if there's a nicer way?

Mar
11
7 months ago
Activity icon

Started a new conversation Vue And Laravel - Ais-configure

I'm using Scout to create a search of some listings with Algolia.

I've created a vue component, which has 2 props

props: {
            category: {
                type: String,
                default: null
            },
            country: {
                type: String,
                default: null
            },
        },

which are passed to the component depending on which page the user is on

<search-component category="{{ $country->category->name }}" country="{{ $country->name }}"></search-component>

Algolia allows you to set some filters so you can only show relevant results. I want to do this based on the above properties.

<ais-configure
    :hitsPerPage="8"
    :filters="category: 'Wildlife' AND country:'South Africa'"
/>

Not knowing much about vue, I'm not sure of the correct syntax to drop in the values in place of the hard coded 'Wildlife' and 'South Africa' above?

Any help is appreciated :-) The Algolia instant search documentation is good, it just doesn't give a specific vue example for this.

Feb
12
8 months ago
Activity icon

Started a new conversation Validating An Input Array

I have a list of checkboxes on a form, like so

<li>
    <input type="checkbox" class="form-check-input" id="voluntary" name="classifications[]" value="Voluntary">
    <label class="form-check-label form__check-label" for="voluntary">Voluntary, Community and Social Enterprise (VCSE)</label>
</li>
<li>
    <input type="checkbox" class="form-check-input" id="workshop" name="classifications[]" value="Workshop">
    <label class="form-check-label form__check-label" for="workshop">Sheltered Workshop</label>
</li>
<li>
    <input type="checkbox" class="form-check-input" id="public-service" name="classifications[]" value="Public Service">
    <label class="form-check-label form__check-label" for="public-service">Public Service Mutual</label>
</li>
<li>
    <input type="checkbox" class="form-check-input" id="n/a" name="classifications[]" value="N/A">
    <label class="form-check-label form__check-label" for="n/a">N/A</label>
</li>

My question is firstly, how would I go about validating it so at least 1 option is required, I've seen a couple of methods but they don't seem to work for me... secondly - how could I show which is checked based off the old values?

Thanks in advance :-)

Feb
08
8 months ago
Activity icon

Started a new conversation Relationship Error

I've started to get an error on my User resource in Nova:

"Argument 1 passed to Laravel\Nova\Resource::resolveFields() must be an instance of Laravel\Nova\Http\Requests\NovaRequest, instance of Illuminate\Http\Request given, called in /var/www/website/nova/src/Resource.php on line 350

My User resource looks like this

return [
            ID::make()->sortable()->OnlyOnForms(),

            Gravatar::make(),

            Text::make('Name')
                ->sortable()
                ->rules('required', 'max:255'),

            Text::make('Email')
                ->sortable()
                ->rules('required', 'email', 'max:254')
                ->creationRules('unique:users,email')
                ->updateRules('unique:users,email,{{resourceId}}'),

            Text::make('Company Name')
                ->sortable()
                ->rules('required', 'max:254'),

            Text::make('Tel')
                ->sortable()
                ->rules('required', 'max:25'),

            Text::make('Industry')
                ->sortable()
                ->hideFromIndex()
                ->rules('max:255'),

            Password::make('Password')
                ->onlyOnForms()
                ->creationRules('required', 'string', 'min:6')
                ->updateRules('nullable', 'string', 'min:6'),

            Boolean::make('Is Admin'),

            Boolean::make('Industries Completed')
                ->hideFromIndex(),

            Boolean::make('References Completed'),

            HasMany::make('References'),

            BelongsToMany::make('Tenders')
        ];

Even when I remove all fields (asides from just the text ones) I still get the above error.

Anyone have any suggestions?

Feb
06
8 months ago
Activity icon

Replied to Password Reset Error

@jlucia yes, all the packages should be up to date. Strange thing is that this works locally on my laptop - same version of php too.

Activity icon

Started a new conversation Password Reset Error

Hey,

I'm using the default laravel 5.7 auth scaffolding. I seem to get the following error when submitting a password reset:

Argument 2 passed to Illuminate\Translation\Translator::getFromJson() must be of the type array, int given, called in /home/forge/sitename.co.uk/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 237

I'm wondering if anyone could point me in the right direction here? I'm not really sure where to look. It seems to be throwing up an error with this

$user->sendPasswordResetNotification(
    $this->tokens->create($user)
);

But I don't know enough to understand where the issue may be.

Thanks!!

Jan
30
8 months ago
Activity icon

Replied to Email Verification Not Being Sent First Time

@nakov Thank you! That's really helpful :-)

Activity icon

Started a new conversation Email Verification Not Being Sent First Time

This is a bit of an odd one, and looking for some ideas as to what may be causing it.

I'm using Laravel 5.7, and have set up the basic auth scaffolding, including email verification. I have my User model setup as per the Laravel docs. For some reason, when a new user registers - the validation email is not sent, however - if they click to resend it, it then comes through fine.

I'm wondering if anyone has any suggestions on what to check, or what might be causing this? I haven't changed any of the default auth controllers (apart from the redirectTo variable)

Jan
22
8 months ago
Activity icon

Replied to Calculating Review Scores

Thanks for all the replies! @digitalized that's about what I needed!

Jan
21
8 months ago
Activity icon

Replied to Calculating Review Scores

Thanks @digitalized - I don't think this is quite right for me though, as firstly I'd need to calculate the average score for all reviews attached to the listing, then get the top 10 listings based on this value.

Activity icon

Started a new conversation Calculating Review Scores

Hi there,

I have a 'Listing' eloquent model, which hasMany 'Reviews'. In the reviews table, I have an overall_rating column.

On the homepage, i'd like to show the top 10 highest overall rated listings. I'm wondering if someone could show me how I would approach this sort of query? For each listing, I'd need to calculate the overall_rating average for each attached review. I can't help but feel the way I'm doing it is a bit messy!

Jan
18
8 months ago
Activity icon

Replied to Sending An Email Notification

Thanks @martenvanurk - this is just what I needed :-)

Activity icon

Started a new conversation Sending An Email Notification

I'm using Nova and have a resource called TenderQuestion. In the front end, a user can ask a question, admin is notified and they from Nova, they can respond to the question. I have set up the relevant eloquent relationships, so a question belongs to a user.

My question is, how can I send an email to the user letting them know their question has been answered from Nova. I've created a Nova action - but I'm unsure how to send an email to the owner of the question?

Dec
07
10 months ago
Activity icon

Replied to Add/Edit Form

Cheers @kvithalani - but how could i show the status of a checkbox (whether it's checked or not) without it erroring?

Activity icon

Started a new conversation Add/Edit Form

Hi,

I have a form that I'm using for both add and edit. For standard inputs, I'm doing the following:

<input type="text" class="form__input" id="legal_name" name="legal_name" value="{{ old('legal_name', $fields->legal_name ?? null) }}">

However, I'm not sure how to approach radio buttons - and showing their status based on either old input, or the $fields model if it exists. My attempts so far have resulted in 'trying to get property of a non-object' errors.

Any pointers appreciated :-)

Nov
16
11 months ago
Nov
13
11 months ago
Activity icon

Started a new conversation Efficient Use Of BelongsToMany

Howdy,

I have a User model, and a Tender model. A User can belong to a number of different Tenders. Having already defined this relationship, my question is about how I can go about showing a user which tenders they are registered on, and which other tenders may be new to them.

I have a dashboard area that would show their registered tenders at the top - and then new tenders below. How could I pass this information to my view without overloading on queries?

Thanks in advance :-)

Nov
11
11 months ago
Activity icon

Replied to Scheduled Task To Update Model Status

@TYKUS - Good spot - stage 1 would finish at 08:59:59, with stage 2 beginning at 09:00 - for example.

Activity icon

Started a new conversation Scheduled Task To Update Model Status

Hi there,

I have a Tender model, which has a number of stages depending on the date...

i.e. Stage 1 ends 23/11/2018 0900 Stage 2 begins: 23/11/2018 0901 Stage 2 ends: 29/11/2018 1730

What would the method look like to loop through each of the tenders, and update the status depending on the current date and time. I'll probably create a new command and schedule it to run every few minutes... just can't work out what the update query would look like.

Thanks in advance!

Oct
24
11 months ago
Activity icon

Started a new conversation Advice On Project Structure

Hi there!

So, I'm working on a project that requires a bit of complex functionality - however, what I'm hesitating on is how to store user profile data.

At the moment, I have a standard user table which records all info from the registration form, and email and password so they can obviously log in.

Each user is going to have quite an in-depth profile - it's split into 8 different sections, and I'd say probably around 60 fields or so. My question is what would be the best way to store this data in the db? I appreciate there may not be a right or wrong way - just interested to hear approaches. I'd figured that I'd create a Profile model which would belong to a user, then just store all the data in a single table?

Apr
02
1 year ago
Activity icon

Started a new conversation Advanced Validation

Hi There,

I have a form that has a few variable sections... for example, I have a select dropdown for employment_status. If a user selects 'Employed' then a number of new fields would appear below (employer_name, job_role, annual_salary). But if they selected 'Unemployed' these extra fields would stay hidden.

My question is how I go about validating these with Laravel. I can't just set them as required because sometimes they may just stay hidden. I've read a bit about the custom conditional validation you can do, but didn't quite understand how to implement it, so wondering if someone could help?

Thanks in advance!

Activity icon

Replied to Old Or Session Data

Thanks @lostdreamer_nl - this was enough to point me in the right direction :-)

Mar
29
1 year ago
Activity icon

Started a new conversation Old Or Session Data

Hi!

So, I have a multi-step form, which validates at each stage and then adds the input into the session, before the data is processed on the final step.

my question is - because I want users to be able to step forward and back between the different stages of the form (there are 4 steps) is there a nicer way to show old input other than:

value="@if(!empty(old('full_name'))){{ old('full_name') }}@else{{ Session::get('step_1.full_name') }}@endif"

I'll need to show old('full_name') before the form step is submitted, but if a user comes back to this step, I'll need to pull the input from the session.

This just looks a bit janky and was wondering if someone would have a better way of approaching this.

Thanks in advance!

Jun
16
3 years ago
Activity icon

Started a new conversation Weird Valet Issue

So, I have a very odd issue that I just can't get my head around.

I have a Laravel 5.2 project set up on my Mac, and I'm using Valet v1.1.12. Since last night, if I try to view /news, the browser just downloads a text file that has the following content:

<br />
<b>Notice</b>:  Undefined index: extension in <b>/Users/dantemple/.composer/vendor/laravel/valet/cli/drivers/ValetDriver.php</b> on line <b>121</b><br />

I've not changed anything in the controller - it's just a standard method that returns a list of news articles.

I have no idea how to resolve this so any tips would be grand!

Jun
15
3 years ago
Activity icon

Replied to Force Download Of S3 File

@spekkionu - This seemed to work :-) Is there any way to get the mime type automatically?

I see if I dd $file, I get the following

stream resource @395 ▼
  crypto: array:4 [▶]
  timed_out: false
  blocked: true
  eof: false
  wrapper_data: array:11 [▼
    0 => "HTTP/1.1 200 OK"
    1 => "x-amz-id-2: V1ivhINJ0XZNNlGCygxnVb9BScvMeG/ok5W02H2OoQBWe56bEm9QCr6dxjIlipsVzrPgQItQcVk="
    2 => "x-amz-request-id: 041EF4A94849F9F6"
    3 => "Date: Wed, 15 Jun 2016 19:26:18 GMT"
    4 => "Last-Modified: Tue, 14 Jun 2016 21:45:19 GMT"
    5 => "ETag: "9e215d8a32c4e07206de5a87bd32b7ba""
    6 => "Accept-Ranges: bytes"
    7 => "Content-Type: image/jpeg"
    8 => "Content-Length: 777485"
    9 => "Server: AmazonS3"
    10 => "Connection: close"
  ]
  wrapper_type: "http"
  stream_type: "tcp_socket/ssl"
  mode: "r"
  unread_bytes: 0
  seekable: false
  options: array:2 [▶]
}

but not sure how to use?

Activity icon

Replied to Force Download Of S3 File

Thanks @spekkionu - however, this gives me the following error

Call to undefined method Symfony\Component\HttpFoundation\StreamedResponse::setContentDisposition()

Jun
14
3 years ago
Activity icon

Replied to Force Download Of S3 File

@cklmercer I get the correct path to the S3 file - if I paste that in another tab, the image file appears.

Activity icon

Started a new conversation Force Download Of S3 File

I've been working with Laravel (5.2) and S3.

I'm pulling my hair out with trying to force a file download from S3. I have the following

$asset = Asset::find($id);
$file =  Storage::disk('s3')->url($asset->asset_path);    
return response()->download($file);

Firstly - I'm not sure if this is 100% correct(?) - and secondly, it just seems to return with a FileNotFoundException - the file doesn't exist, even though it does.

I've given my S3 user full access to the bucket - I just don't know what else to try.

Jul
23
4 years ago
Activity icon

Replied to Eloquent Polymorphic Relationship

@Ruffles The use statements look good to me.

This happens when in my profileController when I try to get the related model

$user = Auth::user();        
$user_type = get_class($user->userable);
Activity icon

Replied to Eloquent Polymorphic Relationship

@Ruffles it's in the user model, and my controller. Not sure what else to try

Activity icon

Replied to Eloquent Polymorphic Relationship

@Ruffles I'm already doing this :-(

Activity icon

Started a new conversation Eloquent Polymorphic Relationship

Hello!

I'm working on a site that requires a few different user types. I'm using polymorphic relationships.

My models are setup like so:

User model (app\User)

public function userable()  
    {
        return $this->morphTo();
    }

Player model (app\Player)

public function user()
    {
        return $this->morphOne('App\User', 'userable');
    }

I'm trying to get the user type in a controller

$user = Auth::user();
$user_type = get_class($user->userable);

but I'm getting a 'Class Player not found' error.

my controller is using the Player model - so not really sure what else to try... it's likely something obvious, but I can't see it!!

I'm using Laravel v5.

Any help is appreciated :-)

Jul
16
4 years ago
Activity icon

Replied to Password Reset With Username

@Francismori7 Yeah - I have an email address :D

The rest of the auth process has been done using a username, and figured it would be interesting to do with the password reset... in the spirit of learning and all that :)

Activity icon

Started a new conversation Password Reset With Username

Hi!

I'm working with a database that uses a username instead of an email address in the db for each user. I'm wondering how difficult it would be to change the default password reset process to work with a username instead of an email address? I'm using laravel 5.1. Any pointers would be appreciated :-)

Apr
27
4 years ago
Activity icon

Replied to Check If User Has Admin Role

Thanks for the advice :-)

Activity icon

Started a new conversation Check If User Has Admin Role

Hi,

I'm working on a Laravel 5 app and I have a couple of different sets of roles and permissions for my users. What I want to do is check if a user has the admin role on login, and redirect to /admin. Would I create a new middleware for this?

Mar
03
4 years ago
Activity icon

Replied to Categories And Subcategories

Just one level of subcategories - I meant the version before 5... my bad!

Activity icon

Started a new conversation Categories And Subcategories

Hey!

I'm editing a Laravel 4.3 site and I have a db table called categories which has the following fields:

  • id
  • parent_id
  • name

I'm trying to output a list in my view of categories, and their subcategories:

  • Category
  • Another Category
    • Subcat
    • Subcat
    • Subcat

I'm not really sure of the best way of achieving this and hoping someone can help point me in the right direction :-)

Jan
19
4 years ago
Activity icon

Started a new conversation Passing Data To A Bootstrap Modal

Hi!

I have a Laravel question and I'm hoping someone can help!

I have a simple admin system, with a list of used vehicles. Each vehicle has an option to edit, delete or quick view. For the quick view, I want the vehicle details to be displayed in a Bootstrap Modal (to save the user going into the edit screen and back again) and I'm just wondering what the best way of doing this is? I'm guessing I can pass the id to the modal, then load a view? I'm just not sure how best to do this :-(

Jan
13
4 years ago
Activity icon

Started a new conversation Laravel 5 Auth Video

I know this has been covered a bit in the past, and there has even been a video already for an earlier version of Laravel 5, but an updated video explaining the Auth process would be super handy - this seems to be a section that has changed quite a bit from laravel 4?