Member Since 5 Years Ago


Consultant at https://burlresearch.com

Experience Points 125,630
Experience Level 26

4,370 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 791
Best Reply Awards 105
Best Reply
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement


    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement


    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

18 Apr
1 week ago

burlresearch left a reply on API Integration

OK, Here's a good hint to get you started. I'll recommend you install GuzzleHTTP - you'll need something to make the http request. The instructions are pretty clear, this is what they are indicating you run to make the connection:

     * Ensure to install GuzzleHTTP for this to work:
     * $ composer require guzzlehttp/guzzle
    public function handle()
        $key = base64_encode('F50368501B084C26A480A7F728E4169E:E72E8F14846445248890038867E3FB03');
        $client = new \GuzzleHttp\Client([
            'headers' => [
                'Authorization' => 'Basic ' . $key,
                'Content-type'  => 'application/json',

        $res = $client->get('https://api.eposnowhq.com/api/v2/product/');

        // An array of the first 200 products...
        $products = json_decode($res->getBody(), true);

        foreach ($products as $index => $product) {
            printf("%03d - [%s] %s\n"
                , $index
                , $product['ProductID']
                , $product['Name']
16 Apr
1 week ago

burlresearch left a reply on Laravel Form Request Custom Error Message For Regex Rule

I wonder if it's not your regex that's not quite right? I think what you have is more permissive than you think, it is testing whether exists in the code, not whether code is entirely that. What if you try this, it may trigger the error you want:

regex:/^[A-Za-z0-9 ]+$/'

burlresearch left a reply on Get Difference Between Two Date Type Column In A Query

@jlrdw I should have been more specific, that I didn't recognize that syntax (with the 3rd arg as date_format). Seems that SQLServer also has a similar function:


burlresearch left a reply on API Integration

Is this a homework assignment or a job interview?

burlresearch left a reply on Get Difference Between Two Date Type Column In A Query

Here is an example of an Eloquent version of what you might be looking for.

It's not clear to me what type of database you're querying, it doesn't look like MySQL syntax, but it also doesn't look like that SQLServer sytax either (but I'm not that familiar with SQLServer...).

No matter, here's an example that works for MySQL, perhaps this will help you:

public function recent() {
    return \DB::table('posts')
        ->selectRaw('*, datediff(created_at, now())')
        ->whereRaw('datediff(created_at, now()) > ?', [-99])
09 Apr
2 weeks ago

burlresearch left a reply on Unique Results

what makes your sub-jobs unique? There must be a property like name or category by which you can tell 2 sub-jobs are different?

01 Apr
3 weeks ago

burlresearch left a reply on Make A Search Form And Show Result On The Same Page

Your [email protected] function is called via a POST request - so return JSON from it, not a view().

Then you'll be able to see the response from the form submission will contain the data that was matched. This is all done asynchronously in Javascript, so you'll have to have a JS function to parse the response, and push the results onto your page.

30 Mar
3 weeks ago

burlresearch left a reply on Best Practice To Store And Output Data

Seems you're having some trouble trying to figure out: "what is a User in your context"

When crafting a database - you have to make some decisions about what your data means to you - then you can worry about the best way to store it.

With what you've given - there are some hints you've given. I think the way I like to think about some of your issues. When modelling a database:

  1. When you're talking about 1-1 relationships of tables, why are you making another table. There are good reasons to do this, sometimes. but often any 1-1 relationship of a table element really just represents a property of that element - why not just put that property on the same table? For a user, these are really properties that could easily be stored on the same table {Last Online, Birthdate, Website, Place of residence, Comment}
  2. If a "User" in your system could have multiple options, then I would think that's no longer a property of your user, but a relationship. So, {E-Mail, Skype, Phone} might be candidates for an alternate contact table where a given user could have multiple associated accounts. So maybe you want to break those out.

It's up to you how you model it, but try to keep things simple as possible, and don't be afraid to change them later, if you think your requirements merit a change.

25 Mar
1 month ago

burlresearch left a reply on If Condition Check Value

Reading this now I sound a little angry! Sorry if the tone was off - it was a little late when I posted.

But, that is a little pet-peeve of mine - ask any of my work-mates, LOL. Glad you asked.

burlresearch left a reply on If Condition Check Value

This is a pet-peeve of mine - remember the if statement branches on the value of a conditional - if your intention is to just return the validity of that, then the if statement is completely redundant - just return the condintional itself!

Maybe this is better:

public function paymentstore(Request $request,$id)

  return ($request->get('amount') <= Registration::findOrFail($id)->charges);
24 Mar
1 month ago

burlresearch left a reply on Merging Collection With Object Keys

I think you're a little incorrect here. It looks like you're creating probably an API Resource out of your collection, and that would "return" a \Illuminate\Http\Resources\Json\JsonResource.

This is not an array, but can be converted to one. So likely you're looking at the output of a controller function, which is converting your API Resource into an array, which is converted to JSON, and shown to you in a browser?

If you want it converted to a PHP Object, then I suppose you could cast it, but I suspect that's actually what you want.

$sampleRes = new SampleResource($all);
$obj = (object) $sampleRes->toArray();

will give you an object, but maybe you can explain what you are doing - this looks like you are a little confused?

burlresearch left a reply on Setting Up Proper Permissions For Laravel App In Ubuntu

You may reuse an existing group if you like. If ever you were to change webservers (maybe unlikely) then you might want a different group to share file access. If you have a non-standard group, then this migration would be simplified. I have used www-data in the past - sometimes that is convenient. The name of the shared group really doesn't matter.

The umask command option is kind of handy. The point is that when you create a new file (like your log-file you mention) then you will want that to be 'group-writeable'. This way, any other entities in that group would also be able to write that file. Avoiding the issue you mention. If you set the umask of your user to umask 002 then any new files or directories will get the inverse of that, by default.

So by default on unix, a files permission is 664 and with umask *002* then you end up with 664 & 002 = 664, which is group-writeable.

You could put in:


umask 002

and every time you login it will be set for you.

23 Mar
1 month ago

burlresearch left a reply on Setting Up Proper Permissions For Laravel App In Ubuntu

There is no right and wrong way to do this, and there will always be alternative solutions - it depends on how really fussy you want to be about system security and all that. Of course it may depend on the client and all sorts of other things, so you have to be a little flexible to other approaches, I always am.

But, since your asking for opinions ... I've setup a lot of servers and this is the approach that I like to use. I think it's reasonably secure (assuming general system security is up to snuff, with regular updates, ufw, controlling open ports and software and user accounts, etc). What I like:

  1. use a non-root account for login
  2. create a new group [say websrv] and set this group as the primary group for both your user account and the webserver account: $ sudo usermod -g websrv nginx
  3. set the umask 0002 for your user account (this means any new files/dirs will be group writeable - this is key)
  4. ensure your project is group writeable: sudo chmod -R ug+rw /var/www/laravel

This way when your webserver (nginx above) or your user writes files into the shared deployment directory, either user will later be able to write, or delete, those files, via the shared group permissions.

You may have to do a little work to make sure that the webserver uses that primary group, IE in the php-fpm config, and in the nginx.conf webserver config (or whatever it is for Apache, if you prefer that).

Maybe there are some security nuts who can criticize this setup, and I wouldn't use the same approach for a Wordpress server, but in terms of long-term facility vs pretty good security + Laravel being security conscious + saving me time and hassle - I find this to be a nice balance. (And have yet to have a server hacked that I've launched, in the last 30 years, so it works for me.)

burlresearch left a reply on HowTo? Create Entity For Users And Editable In Adminpanel?

You can be clever and still use the Artisan generator, if you like:

a make:controller -r -m Item -- Admin\\ItemController

burlresearch left a reply on QUEUES AND JOBS

Sounds like there may be too much context involved to separate the jobs easily - so that might not be right for you.

The Laravel Eventing system could be an option - it's very powerful and may suit what you want better. I've written some tricky SOAP interface systems before that work just this way.

So you could chunk(12) your workload; make the SOAP calls; and dispatch() an async handler depending on what comes back. This would be a nice use of the Queues and Events. Sounds like a job for Redis.

22 Mar
1 month ago

burlresearch left a reply on QUEUES AND JOBS

There is the concept of "Job Chaining" which it sounds like may help you. When you're describing your 'complex job' it sounds as though it's complex because there are several, sequential steps.

You may want to try and create 'simple Jobs' for each step - and then chain those jobs together so the chain forms the complex, and not some single monolith controller / handler.

Sounds like you're definitely on the right path though.

burlresearch left a reply on Retrieve Eloquent Relationships From A Pivot Table While Doing A BelongsToMany

I thought that what you wanted might work too - I gave it a try, but no. Thought that b/c the Pivot is a subclass of Model we might be able to use the relationship directly when we access the ->pivot element, but b/c it acting as the pivot here, and not as the actual relationship, trying to resolve a secondary relation off of the pivot doesn't seem to work.

// from: $ artisan make:model Driver
use Illuminate\Database\Eloquent\Model;

class Driver extends Model
    protected $guarded = ['id'];

    public function cars()
        return $this->belongsToMany(Car::class)
            ->withPivot('id', 'rider_type_id');

// from: $ artisan make:model --pivot CarDriver
use Illuminate\Database\Eloquent\Relations\Pivot;

class CarDriver extends Pivot
    protected $guarded = ['id'];
    public $incrementing = true;

    public function car() { return $this->belongsTo(Car::class); }

    public function driver() { return $this->belongsTo(Driver::class); }

    public function riderType() { return $this->belongsTo(RiderType::class); }

So the best I could do was to use the data id's that come via the ->withPivot() call to lookup the RiderType, either directly, or possibly as it relates to your Pivot class. It would be cool if it worked the way you wanted, but it does make sense why this doesn't work, I suppose.

>>> foreach (Driver::find(3)->cars as $c) {
[!] Aliasing 'CarDriver' to 'App\CarDriver' for this Tinker session.
"{"id":2,"type":"esse","created_at":"2019-03-22 06:20:41","updated_at":"2019-03-22 06:20:41"}"
"{"id":2,"type":"esse","created_at":"2019-03-22 06:20:41","updated_at":"2019-03-22 06:20:41"}"
"{"id":4,"type":"omnis","created_at":"2019-03-22 06:20:41","updated_at":"2019-03-22 06:20:41"}"
"{"id":4,"type":"omnis","created_at":"2019-03-22 06:20:41","updated_at":"2019-03-22 06:20:41"}"

burlresearch left a reply on Select Nearest Cities From Table

I've been playing with this and have confirmed that this raw query works as expected.

$cities = DB::table('articles')
    ->selectRaw('id, name, st_x(location) as lat, st_y(location) as lng, ST_Distance_Sphere(location, POINT(?, ?)) as dist', [$lat, $lng])
    ->having('dist', '<', $distance)

this will return dist in meters, I suppose.

If you want to build it into your Eloquent Model a little more tightly, take a look at this article:


16 Mar
1 month ago

burlresearch left a reply on Redis

You should be able to find the cache.prefix that your app is using:

/srv/laracasts$ artisan tinker
Psy Shell v0.9.9 (PHP 7.1.26-1+ubuntu16.04.1+deb.sury.org+1 — cli) by Justin Hileman
>>> config('cache.prefix')
=> "laracasts_cache"

Then I pushed a value into the cache in a blade file:

        $cval = Cache::remember('welcome', 60, function () { return 'cached value'; });
    <h4> cache: <code> {{ $cval }} </code> </h4>

Then you should be able to find a value in your Redis explorer with the key named by the pattern <cache_prefix>:<key>, and mine from above, was: laracasts_cache:welcome

One thing I did notice, from Redis Desktop Manager, was that the cached values I was storing in my app code were stored in a different Redis Database than the default db0. All my cached values were instead in db1 - so from the command line I had to specify that database in order to see my cached values. Perhaps this is the issue you're running into, also. Tried:

/srv/laracasts$ redis-cli -n 1[1]> get laracasts_cache:welcome
"s:12:\"cached value\";"[1]> 
15 Mar
1 month ago

burlresearch left a reply on Select Nearest Cities From Table

I'm not sure what you mean by query in eloquent for this - since there is a lot of missing information about your model here, but in terms of a query (assuming MySQL?), you could avoid the [incorrect] geometry calculations by using the builtin function ST_Distance_Sphere with something like:

$results = DB::table('articles')
    ->selectRaw('id, ST_Distance_Sphere(location, POINT(?, ?) ) as distance', [$lat, $lng])
    ->having('distance < ?', [$distance])

I kind of inferred your POINT field was called location and the table name (articles). But maybe this will get you on track?

09 Mar
1 month ago

burlresearch left a reply on Attach() On Custom BelongsToMany-Model

OK, I suppose I agree, you could have a Model and simply set the $table in it to the 'correct' pivot table. I do feel this is misleading, though - since artisan will generate the pivot table for you. I created my test like this:

$ artisan make:model --migration --pivot UserRole

and this does create the create the table accordingly: Schema::create('user_role', function (Blueprint $table)

which leads to my assumption. I now see that the ->using function is only to associate the Model, while the underlying table name still needs to be overridden in the relationship definition: ->belongsToMany('App\User', 'user_role')

So I think, @gvstavnev the answer to you original issue, is thus, you must define the intermediate table name in your belongsToMany declaration:


    public function folders() {
        return $this
            ->belongsToMany(Folder::class, 'membership') // <-- this is the addition that you need

burlresearch left a reply on Attach() On Custom BelongsToMany-Model

I understand this, but the example provided in the documentation does not work. From the docs, using the non-standard named pivot table App\UserRole (Laravel by convention would expect App\RoleUser), and trying the using->(...) approach from 5.8:

    public function users()
        return $this->belongsToMany('App\User')->using('App\UserRole');

when you attempt to use the relationship:

Psy Shell v0.9.9 (PHP 7.1.26-1+ubuntu16.04.1+deb.sury.org+1 — cli) by Justin Hileman
>>> Role::first()->users
Illuminate/Database/QueryException with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laracasts_58.role_user' doesn't exist (SQL: select `users`.*, `role_user`.`role_id` as `pivot_role_id`, `role_user`.`user_id` as `pivot_user_id` from `users` inner join `role_user` on `users`.`id` = `role_user`.`user_id` where `role_user`.`role_id` = 1)'

I don't see how this isn't a bug?!

burlresearch left a reply on Attach() On Custom BelongsToMany-Model

No @staudenmeir , the docs are fairly clear about this:


If you would like to define a custom model to represent the intermediate table of your relationship, you may call the using method when defining the relationship. You can combine using and withPivot in order to retrieve columns from the intermediate table.

But on a fresh checkout of Laravel 5.8 the case described in the documentation seems to fail - I this would seem to be a bug, to me. Unless there is something I'm missing?

07 Mar
1 month ago

burlresearch left a reply on Attach() On Custom BelongsToMany-Model

Curious, this does seem to be a bug. The docs are pretty clear that what you're trying should work. I tried the exact same thing as you, in a fresh install of Laravel 5.8.3 and I saw the exact same thing.

I reverted to the "old method" that I would have used in <5.8 by simply using the 2nd argument to specify the pivot table, and that works, of course.

    public function folders()
        return $this->belongsToMany(Folder::class, Membership::class)
            ; // ->using(Membership::class);
    public function users()
        return $this->belongsToMany(User::class, Membership::class)
            ; //->using('App\Membership');

But the docs are very clear this is a new feature of 5.8 - and I agree, it does seem like you found a bug!

13 Feb
2 months ago

burlresearch left a reply on DB Design Help - Primary Index : String Or Numeric

right - seems somehow I've misread your question. So forget the 'activities', seems like what you want to model is Users, and Posts, and the activity you want to track is the interaction of users to posts, in this case 'by liking'.

There are 2 ways I have done this in the past, depending on how many other types of interactions you intend to track. But if it's just the ability to 'like a post' then let's start with that. Either way - you need to create a 3rd, 'pivot table' to track this interaction, here is likely what you're migration will look like;

    public function up()
        Schema::create('post_user', function (Blueprint $table) {
            // $table->string('type');    // this is OPTIONAL, if you need to extend...
            $table->unique(['post_id', 'user_id']);

Then on your User Model, you'll have a many-to-many relation for the posts they like:

    public function likes()
        return $this->belongsToMany(Post::class);
12 Feb
2 months ago

burlresearch left a reply on Laravel Relationship Query

This looks like a straight-up, many-to-many relationship:


once you have your pivot-table defined, which should be called category_country, and your Models defined correctly, as per the link above, then you will be able to reference the category names by looping over them:

11 Feb
2 months ago

burlresearch left a reply on DB Design Help - Primary Index : String Or Numeric

Given that each like for a user is unique - I assume you could just do:

$score = $post->likes->count() * 2

10 Feb
2 months ago

burlresearch left a reply on DB Design Help - Primary Index : String Or Numeric

What you're describing here is a prototypical many-to-many relationship.


You have 2 models that you have described, Users and Activities. You will need a 3rd table to track the many-many relationship between these, Laravel will expect you to name this pivot table: activity_user

To ensure that you cannot enter duplicates, you should place an additional constraint on that pivot table that says $table->unique(['activity_id','user_id']); in your migration.

This should take care perfectly what you want, and make it easy to count your points.

08 Feb
2 months ago

burlresearch left a reply on Laravel One To Many Polymorphic - One (model) To Many (many Types Of Models)

The way I like to handle this, and I think Jeffrey has similar precedents here on Laracasts, is to create a Trait for your Streamable type:

<?php namespace App\Traits;
use App\Stream;

 * Trait Streamable
 * @package App\Traits
trait Streamable {
   * @return \Illuminate\Database\Eloquent\Relations\MorphMany
  public function streams() {
    return $this->morphMany(Stream::class, 'streamable');

then you can easily make your polymorph models share that part with a simple: use Streamable;

In the migration for you would, as typical, have a starter like:

public function up() {
    Schema::create('streams', function (Blueprint $table) {
        // ...

which can be extended to include the common traits.

Does this help clarify things? Or are you asking something more specific?

burlresearch left a reply on Specify Sort Order Of Pivot Table Entries In View

The simple way that I have handled this, in a solution to a similar to what you want, is to use an extra column on the pivot table - called order.

Then when I pull the many relations to the model that is currently displayed, just make sure the extra pivot data is included, in your Model:

return $this->belongsToMany('App\RelatedModel')->withPivot('order');

Then I just make sure I sort the models by their order when their displayed.

On the client-side, using Vue, there is a handy plugin I used to make a nice drag-and-drop UI for the admin-user to reorder their lists, as desired: Vue.Draggable

29 Jan
2 months ago

burlresearch left a reply on AJAX Data

Here is my blade file (using jQuery, since that's what it looks like you were expecting) that might help you.

You simply need to loop over the response from the $ajax call, here using $.each() loop to render the nested lines on your page:


    <div class="container">
        <div class="row">
            <h3>Weather Report</h3>
            <ul id="report"></ul>

      $(document).ready(function () {
          'url': 'https://apis.is/weather/forecasts/is',
          'type': 'GET',
          'dataType': 'json',
          'data': {'stations': '1,422'},
          'success': function (response) {
            let cities = '';
            $.each(response.results, function (key, res) {
              // console.log(res);
              cities += '<li>'
                + ' City name: ' + res.name
                + ' @ ' + res.atime
                + '<ul>'
              $.each(res.forecast, function (fkey, fore) {
                cities += '<li>'
                  + ' ftime: ' + fore.ftime
                  + ' F: ' + fore.F
                  + ' D: ' + fore.D
                  + ' T: ' + fore.T
                  + ' W: ' + fore.W
                  + '</li>'
              cities += '</ul></li>';
24 Jan
3 months ago

burlresearch left a reply on How Can I Use Jquery For One Component In Vue ?

This is a relatively straight forward thing to do. I got it working on my site by:

fetch it using NPM

$ npm install particles.js

then, import with Laravel webpack:


let mix = require('laravel-mix');

mix.js('resources/assets/js/app.js', 'public/js')
  .sass('resources/assets/sass/app.scss', 'public/css')
  .scripts('node_modules/particles.js/particles.js', 'public/particlesjs/particles.js')
  .copy('node_modules/particles.js/demo/js/app.js', 'public/particlesjs/')

Then, from my homepage Blade file, I just pushed it on my scripts stack:


    <script src="{{ asset('particlesjs/particles.js') }}"></script>
        particlesJS.load('particles-js', 'particlesjs/particles.json', function () {
            console.log('callback - particles.js config loaded')

And, I think there was one more config I brought in to configure things:


22 Jan
3 months ago

burlresearch left a reply on Installing Laravel On A Freelancers Machine

Config files will likely be in (on a Mac): /etc/php.ini - check there

burlresearch left a reply on In A Complete Mess With Vue And Charts.js

You basically had most of it. I tidied up what you had - and fixed a couple of the little data issues. Not sure what you're going for exactly, cause your data was a little weird (too many of the same keys...). Here is a working example with some little tweaks:

  <div class="container">
    <div class="row">
      <div class="col">
        <canvas width="300" height="150" ref="chart"></canvas>

  import Chart from 'chart.js';

  export default {
    name: 'GraphJs',
    props: ['temps', 'jdata'],
    components: ['Chart'],

    data() {
      return {
        vtemps: [
          {'hour': '2202', 'temperature': '12'},
          {'hour': '2203', 'temperature': '13'},
          {'hour': '2204', 'temperature': '5'},
          {'hour': '2205', 'temperature': '8'},
          {'hour': '2206', 'temperature': '11'},
          {'hour': '2207', 'temperature': '10'},

    mounted() {
      let context = this.$refs.chart.getContext('2d');

      let cdata = {
        labels: this.vtemps.map(function (i) { return i.hour }),
        datasets: [
            label: 'Hourly Temperatures',
            data: this.vtemps.map(function (i) { return i.temperature }),
            fill: false,
      new Chart(context, {type: 'line', data: cdata});
18 Jan
3 months ago

burlresearch left a reply on Help In Building Eloquent Relationships

This is a big ask - b/c so many moving parts. I'd suggest to

  1. build what you want incrementally, one or two models at a time
  2. focus initially on the links between the models (rather than the properties of the models, this is just additional typing)
  3. test the relationships - then think of expanding to the next model

It's good that you have an overall picture of what you want. But as you build it you will run into little things that will tweak how you round out the schema relations.

Likely I'd start with a Technician model (since that looks central to you) and work out from there.

(I've actually built a Laravel site that essentially does almost the same thing as what you describe.)

From a Laravel command line, I'd say start building the relationships between the core models of your schema:

[email protected]:/srv/trades$ artisan make:model -a -- Technician
Model created successfully.
Created Migration: 2019_01_19_034657_create_technicians_table
Controller created successfully.
[email protected]:/srv/trades$ artisan make:model -a -- Company
Model created successfully.
Created Migration: 2019_01_19_034705_create_companies_table
Controller created successfully.
[email protected]:/srv/trades$ artisan make:model -a -- Customer
Model created successfully.
Created Migration: 2019_01_19_034723_create_customers_table
Controller created successfully.
[email protected]:/srv/trades$ artisan make:model -a -- Service
Model created successfully.
Created Migration: 2019_01_19_034807_create_services_table
Controller created successfully.
[email protected]:/srv/trades$ 
14 Jan
3 months ago

burlresearch left a reply on Vuejs Filter With Checkbox

There is some helpful detail in the VueJS guide for dealing with Filtering, as you want to do:


I have a working example here that you should be able to directly apply to your table variation:

  <div class="container">
    <div class="row">
      <div class="col">

        <div v-for="cat in categoryList">
          <input type="checkbox" :id="cat" :value="cat" v-model="categories">
          <label :for="cat">{{cat}}</label>
        <span>You have chosen: {{ categories }}</span>

      <div class="col">
        <strong>Items in chosen category(s)</strong>

          <li v-for="item in selectedItems"> category: {{item.category}} | name: {{item.name}}</li>

  export default {
    name: 'Checkbox',
    data() {
      return {
        categoryList: ['animal', 'fruit', 'clothes'],
        categories: [],
        items: [
          { id: '1', name: 'apple', description: 'description about product', category: 'fruit', },
          { id: '2', name: 'mango', description: 'description about product', category: 'fruit', },
          { id: '3', name: 'shoes', description: 'description about product', category: 'footwear', },
          { id: '4', name: 'shirt', description: 'description about product', category: 'clothes', },
          { id: '5', name: 'dog', description: 'description about product', category: 'animal', },
          { id: '6', name: 'cat', description: 'description about product', category: 'animal', },
    computed: {
      selectedItems: function () {
        let cats = this.categories;
        return this.items.filter(function (item) {
          return -1 !== _.indexOf(cats, item.category);
11 Jan
3 months ago

burlresearch left a reply on Append Data To Nested Array Collection

You need to know the length of each sub-collection - that's what the '7' represents, would be the 8th item in the collection.

But that should be the idea.

10 Jan
3 months ago

burlresearch left a reply on Append Data To Nested Array Collection

Since you're looking to modify your data array, in place, I think you may want to check out: data_set. With this method you can easily alter your nested structures.

Here is a suggestion that might lead you in the right direction:

data_set($col, 'groups.7.5.port.7.service.5.name', $name);

Or so - you'll have to do some experimenting for how to get the array.length counts...

04 Jan
3 months ago

burlresearch left a reply on Vmware Ubuntu

Looks like you'll need VMware Vagrant plug-in to use it with Homestead. But Homestead will work fine on VMware. The docs are pretty clear on how to get started:


Is there something else you're looking for?

03 Jan
3 months ago

burlresearch left a reply on Move From Sentinel To Laravel Auth

If you're still early in your project - like no production users - then you could likely get away with just installing php artisan make:auth and a migration to copy your user details from the Cartalyst tables to the native Laravel App\User table.

Better to switch earlier than later.

19 Dec
4 months ago

burlresearch left a reply on Datetime Zone Issue

This should come from your config/app.php settings, make sure:

    'timezone' => 'UTC',

is set any that should take care of your default timestamps.

18 Dec
4 months ago

burlresearch left a reply on Laravel Collection Always Returns An Object Instead Of An Array

This is a perfect candidate for which to use an Eloquent: API Resource.

In fact, because you have a hybrid model here you could even use 5 API Resources. One each, to model the 4 pure models, and a 5th to model the hybrid representation that you want to model in your API response.

I have actually built a system very similar to what you're working on, and this is how I do it. The API resources make a perfect solution, not just for exporting to your front-end, but also later for flat-file export and BI-layer consumption.

12 Dec
4 months ago

burlresearch left a reply on How To Open List Where Parent_id 1

Just as I wrote in the explanation. Before you click, this.adverts = [] so the 2nd list will contain no items. When you @click="sendAdvert(category.id)" you will call your HTTP endpoint that will populate the list of child-objects, into your this.adverts.

Then Vue will pickup the change and render the list items, in:

Child Listing (after your Categories)

<ul class="list-group">
    <li v-for="advert in adverts" :id="'advert-'+advert.id" class="list-group-item">{{ advert.name }}</li>
10 Dec
4 months ago

burlresearch left a reply on How To Open List Where Parent_id 1

I think the first thing is to realize that your Category is related to itself, and that you can represent this relation just like any other Eloquent relation.

class Category extends Model {
  public function parent() {
    return $this->belongsTo(Category::class, 'parent_id');

  public function children() {
    return $this->hasMany(Category::class, 'parent_id');

This way, you can get all the children of an object like this:

>>> Category::find(1)->children
=> Illuminate\Database\Eloquent\Collection {
     all: [
       App\Category {
         id: 2,
         parent_id: 1,
         name: "Devil",
         created_at: "2016-08-17 09:58:54",
         updated_at: "2018-04-18 10:34:52",
       App\Category {
         id: 3,
         parent_id: 1,
         name: "Taz",
         created_at: "2017-05-08 00:24:19",
         updated_at: "2018-02-26 20:32:14",

Then your store() method is simply returning the children:

public function store(Request $request)
    $id = $request->id;
    $category = Category::find($id);

    return $category->children;

(Although I don't think this is well-named, this method should really be called children(); and better accessible as a GET request, but you can refactor later.)

Now, when you call: axios.post('adverts/store', { id: id })

Your response data will be adverts as you have it, an array of child objects. I suppose you could add a second list, for the children, in a second list (however you want to handle it):

<ul class="list-group">
    <li v-for="advert in adverts" :id="'advert-'+advert.id" class="list-group-item">{{ advert.name }}</li>
06 Dec
4 months ago

burlresearch left a reply on Static Methods And Method Chaining

In order to chain methods, the trick is to, at the end of each function, return a reference to object that was just called. The object then has a function defined on it for the next thing in the chain.

Your MyStaticMethod is static - so you're probably not returning a reference to the object when returning self. You could try returning new self, but you'll have to test:

    public static function MyStaticMethod($param) {
        // do __METHOD__
        return new self;

this will call the constructor on the current class, and return an object that you can chain.

For the non-static method, if it's just modifying the current object, you can probably just: return $this;

02 Dec
4 months ago

burlresearch left a reply on Mail Not Sending Cc

sounds like an issue more with your mailer, than with how you're sending...

01 Dec
4 months ago

burlresearch left a reply on Jobs Applications Board

You'll want to name your pivot table according the Laravel table naming convention. Of course, you don't have to, but it will make things work a little smoother if you use the name: job_user table.

To define this relationship, three database tables are needed: users, roles, and role_user. The role_user table is derived from the alphabetical order of the related model names, and contains the user_id and role_id columns.


Once that is setup, you'll be able to see if a User has a related Job record with a query, maybe like:

$jobid = 123;
$user = App\User::find(1);
$already_applied = $user->jobs()->where('id', $jobid)->count() > 0;

burlresearch left a reply on Mail Not Sending Cc


The cc method accepts an email address, a user instance, or a collection of users. If you pass an object or collection of objects, the mailer will automatically use their email and name properties when setting the email recipients, so make sure these attributes are available on your objects.

So you should be able to simple pass the user for your to target, and according to docs, a simple email address int he cc field should do the trick.

Mail::to($event->user)  // User object, with `email` field
  ->cc('[email protected]')  // email address should work
  ->send(new AccountRenewalEmail($event->user, $mailcentre, $payment));