lyleyboy

Member Since 5 Years Ago

Staffordshire

Experience Points
31,025
Total
Experience

3,975 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
568
Lessons
Completed
Best Reply Awards
2
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 7
31,025 XP
11 Mar
6 months ago

lyleyboy left a reply on Hide Edit Button For Some Items

Could you just wrap the button in an IF statement?

@if(Auth::user()->admin)

button

@endif

lyleyboy left a reply on Dusk Testing A < Select > Field Just Doesn't Work

No, there isn't anything.

I've tried about every combination of selectors for this.

09 Mar
6 months ago

lyleyboy left a reply on Dusk Testing A < Select > Field Just Doesn't Work

public function testCreatePartner()
    {
        $this->browse(function (Browser $browser) {
            $browser->loginAs(User::find(1))
                ->visit('/admin/partners')
                ->visit('/admin/partner/new')
                ->assertPathIs('//admin/partner/new')
                ->select('.ftna_campaign_id', 1)
                ->type('company_name', 'Example Company')
                ->type('url', 'http://www.google.com')
                ->type('firstname', 'Testy')
                ->type('surname', 'McTesterson')
                ->type('email', '[email protected]')
                ->type('address_1', '1 Test Street')
                ->type('address_2', 'Test area')
                ->type('town', 'Test town')
                ->type('county', 'Testingtonshire')
                ->type('postcode', 'WS9 8LT')
                ->type('phone', '0121 244 7788')
                ->type('password', '123123123')
                ->type('password_confirmation', '123123123')
                ->press('Register')
                ->assertPathIs('//admin/partners')
                ->assertSee('Example Company');
        });
    }
08 Mar
6 months ago

lyleyboy started a new conversation Dusk Testing A < Select > Field Just Doesn't Work

Hi folks,

I'm hoping this is pretty straight forward but I'm using Dusk to test creating a new user (there are a few extra fields compared to the standard)

One field on the form is

<select name="campaign_id" id="campaign_id"
                                    class="ftna_campaign_id form-control {{ $errors->has('campaign_id') ? ' is-invalid' : '' }}">

                                <option value="">-- Please Select --</option>
                                @foreach($campaigns as $campaign)
                                    <option value="{{ $campaign->id }}">{{ $campaign->name }}</option>
                                @endforeach

                            </select>

When I run the dusk test, it fills out all the other fields but this one. The test fails and states that it can't get to the submitted page because the Request catches the fact that the campaign_id isn't set.

I've tried all sorts to get it to work but this is what I have tried

->select('.ftna_campaign_id', 1)

->select('campaign_id', 1)

->select('campaign_id', 'Campaign Name')

Does anyone have any thoughts? Thanks

06 Jun
1 year ago

lyleyboy left a reply on Build Up A Query Inside A Cache::remember

See, I knew it would be easy. I'd gone code blind.

Thank you so much @tykus

lyleyboy started a new conversation Build Up A Query Inside A Cache::remember

Hey folks,

I'm hoping that this is dead easy and I'm being daft (not the first time).

I have the following chunk that mades up an elloquent model based upon a $count variable.

$developments = $this->model->whereIn('status_id', [4, 3])->where('featured', 1);
if ($count > 0) {
    $developments->take($count);
}

return $developments->get();

This works fine, now what I'd like to do is to wrap that block inside a Cache::remember callback

$developments = Cache::remember('featured', env('CACHE_STD_MINUTES'), function ($count) {

  $developments = $this->model->whereIn('status_id', [4, 3])->where('featured', 1);
    if ($count > 0) {
      $developments->take($count);
    }

  return $developments->get();
});

When I run that I get

Too few arguments to function blah\blah\Repositories\{closure}(), 0 passed in 

Hopefully this is a dead simple fix. Cheers

03 Jan
1 year ago

lyleyboy left a reply on Modifying The Url

Do you know what ioncube does? Maybe have a look at that first.

lyleyboy left a reply on How Sync Database From Remote To Server Database

There are many ways to do this.

I think one way might be to run a command that exports the data you need to port over and then import it into the correct table.

Its not the best option at all.

You could even fake a seeder, i.e. ask PHP to write out the file and then run it.

Or you could go the proper route and look at replication, have a look here. https://dev.mysql.com/doc/refman/5.7/en/replication.html

lyleyboy left a reply on How To Simulate User Request Like Domain.com/urlhere

It might help if you explain what you're trying to achieve to be honest. It seems a bit confusing to me. But that could just me be...

lyleyboy left a reply on Error Display

In your blade, check if the Session::get('message') is an array or not.

use get type()

if its an array loop over it and dump out the content, if not just display it.

lyleyboy left a reply on How To Create A New Table And Desired Attributes And 'model For That Table' Only Through Code Not By Using Terminal In Laravel.??

Can't you just create it using good old SQL. Either through DB:: or just write the SQL.

lyleyboy started a new conversation Creating IE11 Compatible JavaScript With Laravel Mix

Hi,

I'm having fun trying to create IE compatible JavaScript. I'm working on a Laravel project that someone else built.

The mix file looks like this

mix.js('resources/assets/js/app.js', 'public/js').extract(['jquery', 'bootstrap-sass', 'slick-carousel']).autoload({
    jquery: ['$', 'window.jQuery', 'jQuery', 'jquery'],
}).sourceMaps().version();

The JavaScript that is coming out of the compiler is as below

webpackJsonp([0],{

/***/ "./node_modules/babel-polyfill/lib/index.js":
/***/ (function(module, exports, __webpack_require__) {

"use strict";
/* WEBPACK VAR INJECTION */(function(global) {

__webpack_require__("./node_modules/core-js/shim.js");

__webpack_require__("./node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js");

__webpack_require__("./node_modules/core-js/fn/regexp/escape.js");

if (global._babelPolyfill) {
  throw new Error("only one instance of babel-polyfill is allowed");
}
global._babelPolyfill = true;

var DEFINE_PROPERTY = "defineProperty";
function define(O, key, value) {
  O[key] || Object[DEFINE_PROPERTY](O, key, {
    writable: true,
    configurable: true,
    value: value
  });
}

define(String.prototype, "padLeft", "".padStart);

THERE IS A LOT MORE ;-)

I'm reading a lot about using babel etc but tbh I've tried what has been suggested but IE11 continues to just ignore the JavaScript.

If you could give me any pointers that would be really great. Or if we could just go back to Gulp... I liked Gulp.

24 Nov
1 year ago

lyleyboy left a reply on Working With View But Not A Component

Hi,

Thanks for this, going to have a go now.

I am using Laravel Mix to compile into a single file as pretty standard.

I need to really get to grips with Vue.

23 Nov
1 year ago

lyleyboy left a reply on Working With View But Not A Component

Hi,

Thanks. I think I understand. So if I wanted to move this off to a different file, how would I do that?

I assume just the script chunk would be moved. But this is my question, its not a component.

I tried this require("./parts/CourseCreate.js"); in my main app.js

That file looks like this.

var courseCreate = new Vue({
    el: "#createCourse",
    data: {
        courseName: "",
        slug: ""
    },
    methods: {
        createSlug: function() {
            //Todo
        }
    }
});

But then I found that I had to comment out the new Vue declaration at the bottom of the app.js as it overwrote my file. I will want to use components later on so I assume I'll need that piece.

I'm fairly sure this is really obvious and I'm being stupid.

Thanks

lyleyboy left a reply on Working With View But Not A Component

I'm in the UK so if I don't answer immediately, I will.

lyleyboy started a new conversation Working With View But Not A Component

Hi,

I'm wondering if I'm doing this properly. I might be totally wrong. I'm in Laravel 5.5 if that helps.

I have a create form which doesn't need to be a component. All I really want to do is take the 'name' field and create a slug from it into the second input. I could do this very easily in vanilla but I really want to understand Vue.

I don't feel like this should be a component, it doesn't have a template per se and I don't want to call it with a tag, I just want some interactivity on the form.

Can someone help me with that? Whats the best way to do it.

I have tried creating a file that I just require and that kind of works but when I

02 Oct
1 year ago

lyleyboy left a reply on Task Model To Table In View

What do you have so far?

I'd suggest User has many Tasks

Loop over the users and then loop the tasks.

Or the other way around. Get the tasks and loop that but get the user info from the task.

Best to work on what you have so far so paste that in and we can look.

lyleyboy left a reply on Adding Extra Information To Session, Based On User Role, Just After Successful Authorization

This one comes up a lot.

Check out the piviot() method. It look something like

$model->pivot()

lyleyboy left a reply on Route View()->first([..., Abort(404)])

You could create a kind of middleware type situation (not an actual middleware) whereby you have a class that you always call for routes. It then checks the file exists and returns a 404 or performs the from call to the route while passing your data.

lyleyboy left a reply on Laravel Seeder Issue

Not 100% I understand what you're saying but in my mind the category_id's need to match up so random number just won't work.

Why not create say 10 categories. Loop over them, then for each category create X new photos. This way you can pass in the category_id.

Hope that helps. Apologies if I have the wrong end of the stick.

lyleyboy left a reply on Integrate Disqus Api With Laravel

Don't see why not. Have a look for a package, its a good bet someone has already done the work.

lyleyboy left a reply on Best Implementation Of A 'setup' Page For A New App?

A multi part form?

Not exactly sure what you're looking for here.

27 Sep
1 year ago

lyleyboy left a reply on Laravel 5.5 API Resources For Collections (standalone Data)

Hmm,

You could change the query to select just the fields you want. Alternatively you can use the https://laravel.com/docs/5.5/collections#method-only method on a collection to just get the properties you want.

lyleyboy left a reply on What Is The Best Way To Create Add Collaborators

I think you need to look into relationships.

Project hasMany collaborators.

Hope that helps

lyleyboy left a reply on Problemas Con Select Dependientes En Laravel

Hola,

¿Puedes editar la pregunta y rodear los trozos de código con `` `CODE Esto hará que sea mucho más fácil de leer. Por el momento no puedo ver realmente lo que está pasando.

lyleyboy left a reply on Populate The Child Table With The Value Of Users Table With A Specific Query

You need to first decide when/where this process needs to happen, it seems to me that you need to read up on Relationships. I'd say that would be the place to start.

lyleyboy left a reply on Spontaneously Created Remember_token

Is there a question you wanted to ask?

lyleyboy left a reply on Create Model And Add Relationship With Transaction(?)

Definitely look into https://laravel.com/docs/5.5/database#database-transactions well worth it in any case where multiple tables are touched.

With regards to the timestamps thing, you can turn them off periodically. So something like this.

$obj = new Object();
$obj->timestamps = false;

do things

$obj->save()
$obj->timestamps = true;

Hope that helps a bit

lyleyboy left a reply on Middleware Redirect Without Page Cache

Have a look at https://laravel.com/docs/5.5/responses#attaching-headers-to-responses

You should be able to do something like this

public function handle($request, Closure $next)
    {
        $response = $next($request);

        $response->headers->set('key', 'value');

        return $response;
    }

Untested!

lyleyboy left a reply on Uploading Sound Blob On Server Using Laravel

Hmm, not one I've ever considered but isn't it just a blob field?

I may well be utterly wrong...

lyleyboy left a reply on Laravel 4.2 Query To Database

Eloquent is reallt good and very powerful but sometimes its just better to write the query yourself. With that in mind I'd look into using DB::raw()

Check out the documentation https://laravel.com/docs/4.2/queries#unions

lyleyboy left a reply on Multi Language Mobile

How do you mean, return to mobile?

I think you need to build a basic API endpoint for this. In the controller or model that you create you can use

Lang::get('whatever');

This will return an array with all the items in that file for the locale that is set.

lyleyboy left a reply on Deleting A Folder Or File Does Not Work

My first port of call would be to check the permissions of the file/folder.

lyleyboy left a reply on Date Format In Select Box

I think you might be digging a bit deep into this one. Just format the date.

$date = date( j/m/Y , strtotime( $request->date )  )

Or a more Laravely way might be to use Carbon

Use this to create a Carbon instance from the passed data.

Carbon::createFromFormat('Y-m-d H', '1975-05-21 22')

And then maybe if you're storing this back to a database you could

Carbon::createFromFormat('Y-m-d H', '1975-05-21 22')->toDateTimeString(); 

lyleyboy left a reply on Multi Language

Laravel will return the data to you based on the locale set. By default the locale is I believe set to en however you can set this using App::setLocale($locale); and passing the locale you need into it.

Hope that helps.

lyleyboy left a reply on Faker/Factory Not Found On Heroku Db:seed

The first thing I would check is composer dump-autoload

I've never used Heroku so its a bit of a guess.

lyleyboy left a reply on Help With My Package

Not sure I have the correct answer but you could try using a cookie instead. I know its possibly not the answer you were looking for but it should work.

On a side note, brilliant idea for a package, I love it!

lyleyboy left a reply on Fire Click Event On Div Before A

Have a read about event bubbling. This is basically because your mouse is effectively over multiple elements in the DOM ALL the events fire.

You're best bet, since you're using jQuery would possibly be to catch the click on the item you don't want to be clicked and preventDefault() on it.

Then when/if you want to you can trigger the click event using this

$("a").trigger("click");

Untested but it should work.

lyleyboy left a reply on Can't Fetch Data From Relation Table In Laravel 5.5

You first step should be to dd() the object. Post that here and we can see whats going on.

lyleyboy left a reply on How To Develop Mouse Hover Icon Display System

Do you have anything you could show as to what you have?

Most of it can be done with CSS but some functionality might be better/easier achieved with JavaScript.

lyleyboy left a reply on How To Retrieve Image From Database And Display It On View Using Blade In Laravel

This should be pretty straight forward.

In the view do something like this

<img src="{{ $object->image_path }}" alt="Any alt text"/>

That should work although completely untested.

lyleyboy left a reply on Online Users Problem

Okay, what is the problem?

Currently I can't answer an question because there isn't one.

That said I'd consider something like...

  • Add a field in your users table called "last_visited_at" or similar.
  • In a middleware catch the $user and update that time.
  • Create a view/controller set up and barf out the data.

Dead easy.

Of course there are a million ways to skin any cat...

lyleyboy left a reply on UI Generation From Model

I'd be interested to hear about it. I have to admit that I've considered building something to do this but never really got there.

lyleyboy left a reply on Laravel Inserting Related Data

Firstly I would have a good look at Transactions. Just to make sure that since you're interacting with more than one table, that if one process fails, the whole chunk in backed out so as not to create any duff data. https://laravel.com/docs/5.5/database#database-transactions

If the second method is giving you a problem it might pay you to create your own create method. In that you can pass the $user object to catch its data.

Also there are specific methods for creating relational data. Have a look for attach() method.

Hope that helps.

lyleyboy left a reply on Displaying Data For An Intermediary Table

If I understand you correctly I understand this one can be a doozy and there isn't much in the way of documentation on it.

Have a look into the PIVOT method

echo $role->pivot->created_at; <- Straight from the docs.

You should be able to dig into the pivot data using that.

lyleyboy left a reply on Extract Code To Partials

Hi all,

By way of an update I have this all working now. BUT i'm not sure I'm doing the 'right' thing.

I don't currently have any components. I have a folder called instances (Maybe not the best name but, naming is hard) where I put a chunk of code that refers to a page or process.

It works but is it best practise.

lyleyboy left a reply on How To Get The Session Remaining Time

Hey,

I'm looking for the exact same thing. I have a multipage form which stores state in session and could potentially take the user a good time to complete.

I'm considering changing the storage to cookie or maybe localstorage. Not sure.

Help / Advice would be greatly appreciated.

22 Sep
2 years ago

lyleyboy left a reply on Vue And Passing Account_id With Axios

Ah. Good plan. I can fudge together some kind of algorithm to generate something.

No idea why I didn’t consider that.

Thanks.

lyleyboy started a new conversation Vue And Passing Account_id With Axios

Hey,

I'm just learning Vue and I'm selection some data with axios. I need to pass the users account_id to from Vue to the API routes of my Laravel application. Obviously I don't want this to be editable by the user as it would effect their results. In effect they could see other users data.

Does anyone have any good advice on how to do that?

The account_id is stored on the user object, but I don't want to dump that out into my javascript . really.

Thanks for your help.

lyleyboy started a new conversation Extract Code To Partials

Hey all,

Now first off, I'm new to Vue, so apologies if I'm really getting things wrong.

I have a form which I want to add some basic actions on it. That form is a Laravel view which has some data loaded into a select element. I want to catch the change on the select and based upon its value load in some data with axios.

All I really want to know it the best way to go about that. To me it doesn't feel like a component because I don't want/need a template or tag.

So I really want just to add this to my app.js BUT that feels dirty, so could I/should I move that out to another file to be imported to keep things tidy.

If I do move it to a sub folder and import it. I get a "Uncaught ReferenceError: Vue is not defined" error.

I'm open to advice and pointers.

Thanks in advance.