Member Since 1 Year Ago

Software Engineer at Self employed

Experience Points 5,830
Experience Level 2

4,170 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 13
Best Reply Awards 6
Best Reply
  • 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.


    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.


    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.

13 Sep
6 days ago

artcore left a reply on WithSwiftMessage Callback Woes

Sure but I doubt you find it useful - it's not a facade as in the way Laravel has facades, just a wrapper facade. It's using multiple jobs to get certain things done like setting headers.

public function handle(Swift_Message $message)
   * @var array $from
   * @var array $to
   * @var array $cc
   * @var array $bcc
   * @var array $messages
   * @var string $subject
   * @var array $replyTo
   * @var array $headers

  $this->run(SubjectJob::class, ['subject' => &$subject]);
  $this->run(ContentTypeJob::class, ['message' => &$messages]);

  $main = array_shift($messages);

   ->setBody($main->content, $main->type);

  foreach ($messages as $part)
   $message->addPart($part->content, $part->type);

  if (isset($headers))
     'headers' => $headers,
     'message' => &$message,

  if (isset($to))

  if (isset($cc))

  $this->run(SendMessageJob::class, ['message' => $message]);

add HeadersJob

 public function handle()
  $headers = $this->message->getHeaders();

   * @var \Swift_Mime_Headers_ParameterizedHeader $header

  foreach ($this->headers as $param => $value)
   $header = $headers->get($param);

   if (!$header)
    $headers->addParameterizedHeader($param, $value);

check conten type

public function handle()
  foreach ($this->message as $message)
   if ($message->content instanceof Mailable)
    $message->content = $message->content->render();

   if (strpos($message->content, '<!DOCTYPE', 0) !== false)
    $message->type = 'text/html';

   elseif (strpos($message->content, '<?xml', 0) !== false)
    $message->type = 'text/xml';

    $message->type = 'text/plain';

  return $this->message;


class SendMessageJob extends QueueableJob

 protected $message;

  * @param $message \Swift_Message
 public function __construct($message)
  $this->message = $message;

 public function handle(Swift_Mailer $mailer)
   return $mailer->send($this->message);
20 Aug
4 weeks ago

artcore left a reply on WithSwiftMessage Callback Woes

Solved it by writing a new mailer facade for Swift. Simply can't get the withSwiftMessage callback to behave like in L5.5 Cheers

19 Aug
1 month ago

artcore started a new conversation WithSwiftMessage Callback Woes

Hi guys,

I used L5.5 for years for sending mails and changing the body type was never an issue. I regularly send text/xml also. But since 5.6 the processing of the swift message is done after the addContent and it never overrides this using the Closure, again like it was the case prior to 5.5.

From the docs:

withSwiftMessage Callbacks In previous releases of Laravel, Swift Messages customization callbacks registered using withSwiftMessage were called after the content was already encoded and added to the message. These callbacks are now called before the content is added, which allows you to customize the encoding or other message options as needed.

Example that worked until I upgraded to 5.8

`->withSwiftMessage(function (\Swift_Message $message) {

$message->setContentType('text/html'); });`

The Mailer method responsible:

    if (isset($view)) {
        $message->setBody($this->renderView($view, $data), 'text/html');

    if (isset($plain)) {
        $method = isset($view) ? 'addPart' : 'setBody';

        $message->$method($this->renderView($plain, $data), 'text/plain');

    if (isset($raw)) {
        $method = (isset($view) || isset($plain)) ? 'addPart' : 'setBody';

        $message->$method($raw, 'text/plain');

My $text is a string so the addContent method the the L5.8 Mailer sets the body to text/plain. But I'm not able to override this with the withSwiftMessage Other than extending the Mailer class, can anyone share a solution or any insight to what I may be doing wrong?

  ->raw($text, function ($message) use ($mailable, $subscriber) {

     * @var \Swift_Message $message
    $body = $message->getBody();

    $mailBody = str_replace('token', $subscriber->token, $body);
    $message->setBody($mailBody, 'text/html'); //this doesn't take anymore

08 Aug
1 month ago

artcore left a reply on On-the-fly Attribute

I'll share my solution to create a nested set of a 1 dimensional array since I believe this is what you're after

class RecursiveTreeTransformer
  public $result = [];

  public function generate(array &$collection, $start, $branch)
    $result = [];
    foreach ($collection as $item)
      if ($item->{$branch} === $start)
        $branches = $this->generate($collection, $item->id, $branch);

        if ($branches)
          $item->branches = $branches;

        $result[] = $item;

    return $result;

  public function generateAll(array &$collection, $start, $branch)
    foreach ($collection as $item)
      if ($item->{$branch} === $start)
        $branches = $this->generate($collection, $item->id, $branch);

        if ($branches)
          $item->branches = $branches;

        $this->result[] = $item;
        $this->result[] = $item;

    return $this->result;

And an example of usage. Ignore the non-laravel parts, but it should give you an idea

class IndexCategoryJob extends Job
  public function handle(CategoryModel $repository, RecursiveTreeTransformer $collection)
    $results = $repository
      ->where('locale', Condition::equals(app()->getLocale()))
      ->orderBy('id', 'ASC')

     $results = $collection->generateAll($results, '0', 'parent_id');
03 Aug
1 month ago

artcore left a reply on How Would You Go About Building This...?

Sounds like a catalog to me (similar to ecommerce) where a building,parking,land,etc are items and attributes are many-to-many.

I have something like this

Attribute Group : Property Feature --- Attribute : Leisure ------ Value : Balcony

Attribute Group : Construction --- Attribute : Allow ------ Value : true

Item table Attribute table Attribute group table Attribute value table --- I'm storing unique values to be reused

Item_Attribute_Values table item_id group_id attribute_id value_id

Get item with pivot item_attribute_values and hang the descriptions,images etc on the objects.

Hope it helps ;)

21 Jul
1 month ago

artcore left a reply on Best Way To Secure Healthcare Data In DB

How about using multiple databases spread across multiple DCs using ssh auth with public/private keys?

09 Jul
2 months ago

artcore left a reply on Best Practices For Location And Address Management

I had a similar need and created the following tables account account_companies account_addresses account_relations ...and also account_emails, ...phones,, fb etc), each account can have multiple everything and in relations I'm adding related_account_id, account id, description(e.g. Employee)

The name on an account that is only a company is null, account companies has the name in that case.

22 Jun
2 months ago

artcore left a reply on Looking For Elegant PHP Process Runner

I'm surely not on your level but what you describe with a per process setup is what I deal with mostly. Having many cogs async or not and depending on eachother or not. I find lucid architecture very helpful.

Controller or command serves a Feature, and this has a couple of Laravel jobs which can be queued or not. Jobs that often are used together can be combined in an Operation, also from the Feature class

11 Jun
3 months ago

artcore left a reply on How To Protect Laravel Website?

it's often an upload script that can even be on a neighboring account. In that case the server security is like a sieve I've seen it and they either used joomla1.5, wordpress(theme and plugin editor) or opencart(product upload) upload script. If it's uploaded to a publicly accessible folder...

artcore left a reply on New CSS Only Updates When Hard-refreshing(ctrl + F5)

I always just keep the browser developer tools open with 'cache disabled' checked

03 Jun
3 months ago

artcore left a reply on What Web Browsers That Are Lightweight But Are Decent With Web Development?

Chromium is working well on my arch+kde I don't know what ppl like about the latest firefox, it's a memory hog

artcore left a reply on Design Patterns

Hi Bobby,

I prefer to read and looking fw to your posts. Maybe throw in some DDD ;)

30 May
3 months ago

artcore left a reply on Laravel RESTful Shopping Cart

Just a wild thought...are you using an authentication id for the api unique to the visitor? I would use that to store a json object holding the cart data. You need some sort of state persistence and this is at least without a session. I wouldn't use a cookie as they are unreliable and could be tampered with.

28 May
3 months ago

artcore left a reply on Which Editor Do You Use To Work?

PhpStorm on arch linux + kde plasma

  • The nice thing here is that storm updates easily via AUR. on Windows I always had to uninstall the previous first

artcore left a reply on Working With Mod Security Enabled. Intermittent 403 Response.

It reminds me of an issue I once had. Try in your php.ini or .user.ini = 256; = 256; = 256;
suhosin.request.max_array_index_length = 256;
suhosin.request.max_varname_length = 256;
suhosin.request.max_array_depth = 256;

Assuming you don't have root access to check the logs for which rule triggered the 403 so it's a shot in the dark.

Hope it helps or put you on track...

27 May
3 months ago

artcore left a reply on Access DigitalOcean From Windows With SSH

Cool. It seems vsc has an sql extension:

I'm on phpstorm which has datagrip built in, can't live without ;)

artcore left a reply on Access DigitalOcean From Windows With SSH


I don't know what you're using for an editor, but IDEs like phpstorm, netbeans, aptana have built in tools to connect to your server via ssh as well as remote db access. I assume Laravel Forge generated the public/private keys and the password?

If so you can easily setup connections in these IDEs. Download the private key and you're good to go.

.env is also easily accessed and edited this way.

Do check if Forge has remote db support, usually you have to enable this and perhaps open firewall ports + allow mysql to connect not only from localhost (lock remote access to your IP though).

22 May
3 months ago

artcore left a reply on Help With Shirt -> Colors -> Sizes Laravel Relationship

I would suggest renaming the color,size options to a general name: product_options You would have the following tables: products, options, product_option. The latter being a pivot table with just product_id and option_id. So sizes, colors and other options in one table.

Take note of the table naming as Laravel uses that to build the relations.

If you at some point want to add a fabric option you would be all set.

The same applies to product categories,images,prices and attributes. All with pivots And probably a xyz_descriptions tables with language/locale as one-to-many

18 May
4 months ago

artcore left a reply on Having A Very Rough Time Learning Laravel

God morning (8am here)

I was in the same boot, now at 5 years of coding, 1.5 years with Laravel, with no prior experience. I had the same feeling about these abstract seemingly complex concepts but they will sink in when you just start using what you know today. Laravel doesn't force you to use anything specific as long as you understand how to set up a route, you're good to go. No need to understand the container(registry pattern on steroids?) or reflection api (get all info on a class?)

Meanwhile start a few side projects to learn about SOLID principles ( and use a decent IDE (PhpStorm) which allows you to 'follow' the logic (control+b to open the file where a certain method is located and trying to understand how Taylor constructed it is what I often do)

Hope it helps. I'm not the pro I want to be either but it doesn't stop me from building great apps ;)

08 May
4 months ago

artcore left a reply on Load Data For Month Selected

I've been using in combination with On change let the bootstraptable send a query with start and end dates. In your controller you can fetch that in the Request params and than send back the data as json. You have to create your array items in such manner that each row has subsequent monthly data. It's straightforward but if you're not too experienced will take a bit of effort and persistence, but these tools work nicely :) BTW bootstraptable supports excel export as well as pdf, csv and others

03 May
4 months ago

artcore left a reply on Transpile CKEditor To ES5 Using Webpack/Laravel Mix

The following may not help you but I quit webpack over parcel Virtually zero config, just point and shoot. I'm creating gzipped assets from my dev in node and use these as production. Works great

Here's an example of my package.json The browserlist option takes care of all. Note that this setup also has treeshaking.

  "name": "collection",
  "version": "1.0.0",
  "private": true,
  "description": "Display and filter data",
  "repository": {},
  "browserslist": [
    "last 2 versions",
    "> 1%",
    "not ie <= 8"
  "main": "../../../index.js",
  "scripts": {
    "dev": "parcel *.js",
    "build-collection": "parcel build *.js --no-source-maps --experimental-scope-hoisting",
    "watch-collection": "parcel watch *.js --no-source-maps"
  "keywords": [],
  "author": ",
  "license": "ISC",
  "dependencies": {},
  "devDependencies": {
    "parcel-plugin-compress": "^1.0.9"
  "compress": {
    "brotli": {
      "enabled": false

artcore left a reply on Auth Middleware In Routes Vs In Controller

Keep in mind that having a closure in your routes will prevent caching as they can't be serialized. So preferrably use ...->middleware(...) on the routes or for certain methods, add it to the controller constructor.

26 Apr
4 months ago

artcore left a reply on Search Function Laravel 5.8 Add Detail To Search Logic

Take a look at this

It's adding a column to your results with a match relevance based on several methods including levenshtein. 'smt' would give smoothie as well as 'Salad with Mayonnaise Topping`. I wrote my own version of it as I'm not using eloquent but hopefully you get inspiration from it.

23 Apr
4 months ago

artcore left a reply on How Much Of Code Syntax You Guys Remember?

I find myself writing js in php files if I spent a lot of time in js realms Like in php $Array.slice(0,10)

19 Apr
5 months ago

artcore left a reply on Problem With Pagination In Combination With Adding New Records

Are they loaded over ajax? You could store the current 10 IDs and have the next call exclude any posts in that array.

18 Apr
5 months ago

artcore left a reply on Laravel Blade And Javascript

Wrap it inside a dom ready event?

document.addEventListener('DOMContentLoaded', function(){


     format: 'mm-dd-yyyy'



artcore left a reply on Select With Over 10.000 Records

@neflictus This library works nicely with jQuery: Take note that you need to have a results property and a text + id which you can set in the controller. These are used to populate your input values upon selecting.

I copied below from the documentation, to give you an idea.

  ajax: {
    url: '',
    data: function (params) {
      var query = {
        search: params.term // filter your Model with this query as typed by the user

      // Query parameters will be ?search=[term]&page=[page]
      return query;
//in your controller:
return response()->json(['results'=>$yourData]);

//in your frontend it will appear like this 
  "results": [
      "id": 1,
      "text": "Option 1"
      "id": 2,
      "text": "Option 2"
13 Apr
5 months ago

artcore left a reply on Laravel Charts To PDF Possible??

Depending on your charts app you can export them as image and add to pdf easily. e.g. highCharts that has this option via their api or locally with e.g. phantomJS but I never went through that hassle.

11 Apr
5 months ago

artcore left a reply on How To Handle Image Gallery To Have The Same Height And Width

I've only done a single but multiple croppers just work on different elements. You would have to add a listener to the parent containing all cropper elements and take it from there.

Upon cropping I let cropperjs put the base64 encoded image on a hidden input and simply decode it on the server side.

I'll copy some here for you (still in dev, unpolished) The image name and file location are also inputs to allow me to store a reference to the file as well as clean up the filename. See the job handler at the end

@section('title', 'Catalog Image Form')
  <link href="{{ asset('public/assets/collection/collection.css') }}" rel="stylesheet" type="text/css" media="all">
  <link href="{{ asset('public/assets/catalog/css/custom.css') }}" rel="stylesheet" type="text/css" media="all">
  <link href="{{ asset('public/assets/core/cropper.min.css') }}" rel="stylesheet" type="text/css" media="all">
  <div class="container">

    <div class="card mt-5">
      <div class="card-header">
          <i class="fa fa-pencil position-left"></i>
          <span class="text-semibold">{{ is_object($data) ? 'Edit' : 'Add' }}</span> Image:
        <div class="heading-elements">
          <a class="btn btn-warning btn-xs" role="button" title="Cancel" href="{{ route('image.index') }}">
            <i class="fa fa-reply"></i>

    <div class="row justify-content-center mt-5">
      <div class="col-12">
        <form id="form" method="POST"
              action="{{ is_object($data) ? route('image.update', $data->id) : route('') }}"

            {{ method_field('PUT') }}

          {{ csrf_field() }}

          <div class="row align-items-center">
            <fieldset class="col-md-5 col-xs-12 card">

              <div class="btn-group btn-block">
                <a class="btn btn-danger" role="button" title="Cancel" href="{{ route('image.index') }}">Cancel</a>
                <button form="form" type="submit" class="btn btn-success" role="button" title="Save">Save</button>

              <div class="form-group mt-3">
                <div class="custom-file">
                  <label class="custom-file-label" for="location">{{ $data->location ?? old('image.location') ?? 'Choose file' }}</label>
                  <input type="file"
                         class="custom-file-input form-control"
                  <input type="hidden"
                         value="{{ $data->location ?? old('image.location') }}">
                  <input type="hidden"

              <div class="form-group" data-select="link" data-collection="lookup">
                <input type="text"
                       placeholder="add link"
              <div class="form-group mt-5 mb-5">
                <ul id="link-list" class="list-group list-group-flush">
                  <li class="list-group-item active">Linked To</li>
                    @foreach($data->links as $link)
                      <li class="list-group-item d-flex justify-content-between align-items-center deletable">
                        <span class="badge badge-{{ $link->item === 'product' ? 'primary' : 'dark' }}">{{ $link->item }}</span>&nbsp;
                        <span class="btn-block">{{ $link->title }}</span>
                        <span class="btn btn-sm btn-danger delete"><i class="fa fa-trash"></i></span>
                        <input type="hidden" name="links[{{ $link->item }}][]" value="{{ $link->id }}">

              <div class="form-group">
                <label class="col-form-label" for="status">Status</label>
                <input id="status" type="number"
                       value="{{ $data->status ?? old('image.status') }}"

            <div class="col-md-7 col-xs-12">

              <div id="controls" class="btn-group btn-group-justified mb-5">
                {{--<button class="btn btn-outline-danger" data-method="disable" title="Disable"><span class="fa fa-lock"></span></button>--}}
                {{--<button class="btn btn-outline-success" data-method="enable" title="Enable"><span class="fa fa-unlock"></span></button>--}}
                <button class="btn btn-outline-primary" data-method="reset" title="Reset"><span class="fa fa-refresh"></span></button>

              <div id="preview">
                <img src="{{ isset($data->location)
              ? asset('public/assets/catalog/img/item/'.$data->location)
              : '' }}" alt="">
  <script src="{{ asset('public/assets/core/cropper.min.js')}}"></script>
  <script type="module">
    const fileInput = document.getElementById('location'),
          preview   = document.getElementById('preview'),
          input     = document.querySelector('input[name="image[crop]"]'),
          controls  = document.getElementById('controls');

    let cropper;

    const crop = () =>
      const set = () =>
        input.value = cropper.getCroppedCanvas(
            width:                 400,
            height:                600,
            // fillColor: '#fff',
            imageSmoothingEnabled: true,
            imageSmoothingQuality: 'high'
          }).toDataURL("image/png", 100);

      const image = preview.querySelector('img');
      cropper = new Cropper(image,
          minContainerWidth:  404,
          minContainerHeight: 606,
          minCropBoxWidth:    404,
          minCropBoxHeight:   606,
          wheelZoomRatio:     0.1,
          autoCropArea:       1,
          ready:              event =>

      image.addEventListener('cropend', (event) =>
      image.addEventListener('cropmove', (event) =>
      image.addEventListener('zoom', (event) =>


    fileInput.addEventListener('change', event =>
      const fileName =[0].name; = fileName; = fileName;

      preview.innerHTML = `<img alt="" src="${URL.createObjectURL([0])}">`;

      // cropper.destroy();
      setTimeout(() =>
      }, 300);

    controls.addEventListener('click', e =>
      const method ='data-method');

      switch (method)
        case 'reset':
        case 'enable':
        case 'disable':

    }, false);
  <script type="module">
    import List    from "{{ asset('public/assets/collection/markup/item.js')}}";
    import suggest from "{{ asset('public/assets/collection/templates/link.js')}}";
    import action  from "{{ asset('public/assets/collection/events/action-link.js')}}";

    (new List('{{ route('catalog-items') }}'))
      .renderWhen('link', 5)
          action: action,
          title:  ['title', 'item']

and the backend which is a job

<?php namespace Extend\Catalog\Domains\Image;

use Illuminate\Filesystem\Filesystem;
use Illuminate\Http\UploadedFile;
use Lucid\Foundation\Job;

class MoveImageJob extends Job

   * @var UploadedFile $file
  private $file, $crop, $location;

  public function __construct($file, $crop, $location)
    $this->file     = $file;
    $this->crop     = $crop;
    $this->location = $location;

  public function handle(Filesystem $filesystem)
      if ($this->file || $this->crop)
        $file = $this->crop ? base64_decode(str_replace('data:image/png;base64,', '', $this->crop)) : null;

        if (!$file && $this->file instanceof UploadedFile)
          $file = $this->file->get();

        if (!$file)
          return false;

        $fileName = strtolower(str_replace(' ', '-', $this->location));

          config('catalog.disks.archive.folder') . $fileName, $file);

        return $fileName;
    catch (\Exception $e)

artcore left a reply on How To Handle Image Gallery To Have The Same Height And Width

I had the same requirement and ended up using I let the user fit the image inside a fixed width box - multiple croppers are supported. There's a related vue project here but I'm using the vanilla version myself - I have no experience with vue

08 Apr
5 months ago

artcore left a reply on Dispatch

Goedemorgen Bobby! I guess you didn't have to look it up first ;)

artcore left a reply on Dispatch

Had to look it up too as you never know with js nowadays... dispatch() is from a 3rd party library, namely redux. It seems to be a callback for an async action.

03 Apr
5 months ago

artcore left a reply on Laravel 5.8 Access Denied For User 'root'@'localhost' (using Password: YES)

Maybe DB_PASSWORD="1234#" would work. I usually stay away from hashes in passwords ever since my sql app tripped over it. DataGrid/phpStorm

01 Apr
5 months ago

artcore left a reply on Can Not Use Variable Outside Of If Statement

You should always initialize your variables and use strict comparisons === Personally I leave out {} if it's only one statement, but it's personal.

public function getStuff(){

    $push = '';

    if ($insert->free_meal === '1')
        $push = 'Guest is also eligible for a Free Meal';

    return $push; 

artcore left a reply on How Do I Become Good At Programming

Coding is art and creating an app from scratch takes a lot of planning and imagination. It's easy to get overwhelmed especially if you expect yourself to write at the level of Laravel's base.

In general I'd say; allow yourself to be productive with your current skill set.

And creativity only flourishes with small parts, the bigger the construct of any concept in your mind, the less flexible it will be.

This, from almost 20 years of teaching music and now applied to coding (in case you're wondering, it's paying better...) Been at it for 6 years almost and each few months there's a natural improvement in understanding and thus coding level.

26 Mar
5 months ago

artcore left a reply on How To Prevent Executing Parent Div Class On Clicking Div Child

Behind the scenes jQuery loops through the elements and attaches an event listener to each. Preventing default is per element and clicking a div has no default action anyway so it gets executed for all divs with class="load". You can probably use e.stopPropagation(); or e.stopImmediatePropgation(); to prevent the bubbling up the dom.

If you have many of these divs it's better to have 1 listener on a parent and check to perform the action once. You still need to stop the bubbling up though.

24 Mar
5 months ago

artcore left a reply on Only Update Db Field If Input Is Set

@KGP43 - You're welcome, and Laravel validation is one of the best time savers for sure ;)

artcore left a reply on Only Update Db Field If Input Is Set

It may be possible to use

    'inlet_id' => 'sometimes|required|numeric',
    'outlet_id' => 'sometimes|required|numeric',

This validates when present.

Or if 'inlet' is always first to be added, use required_with,inlet_id on 'outlet_id' Laravel has some very flexible options here ;)

22 Mar
5 months ago

artcore left a reply on Ajax Incomplete Request Making

Wild guess: your route has probably only 1 param? Route::get('endpoint/{pid}/{another?}');

21 Mar
5 months ago

artcore left a reply on How To Structure Controller For AJAX And CRUD Endpoints?

Since your axxios headers are like that try if ($request->isXmlHttpRequest()) Btw, I'm also doing this dual thing with view + ajax data, pretty handy

20 Mar
5 months ago

artcore left a reply on Laravel's Localization On JavaScript Variables

You could add a json encoded array to your view in which you gather the translated strings.

$ratings = 
    json_encode([ 'ratings' => 
            'one`=> trans('rating_one')

view('...', ['ratings' => $ratings]);

And then access it like const ratings = {{ $ratings }}, and in your js as

I believe Jeffrey has a package to send js variables to the view also, but it should be something similar to this.

17 Mar
6 months ago

artcore left a reply on Problem With Infinite Scroll Select, In Laravel 5.5

Have a look at It supports pagination/infinite scrolling.

If you want to implement it yourself and you can spare the time to build it; fetch the data over ajax in javascript and do array.slice() + append or replace the select options on a scroll event.

artcore left a reply on Signature Pad With Ajax

It looks like you're storing the base64 encoded image from the form post to the db. Then why are you trying to store it to disk also? You can directly use it as <img src="data:image/png;base64,{{ signature }}">. In any case, the error is clear, you are handing it a directory while it expects a file.

From the docs: Storage::put('file.jpg', $contents);

Your filename is what you assigned to $sig. It's probably a good idea to be more verbose with your variable naming. A month from now you won't know it this is the actual image or something else.

$contents are your base64 endoded image so you have to run it through base64_decode()

Prepend file.jpg with the folder structure you want to store the file in. Storage::put(base_path().'/signatures/2019-03/file.jpg', $contents);

On a side note, since you asked for something obvious, don't let clients pressure you into half-assed code. They will wait if you tell'm to ;)

16 Mar
6 months ago

artcore left a reply on Laravel Update Or Remove

Or keep it simple? Assuming the items belong to a parent... Delete the items from items_table where foreign_key = ? Insert all items from the form into items_table. Use a DB transaction so you don't delete anything if the next action fails for any reason.

artcore left a reply on How To Restrict/limit Resource Edit Without An Login System?

Store a cookie on the PC who created it? That way when a session expires you would still be able to check it (and tell them not to delete cookies)

artcore left a reply on Why Using : Let Self = This?

Yeh, it's a real improvement. Using it every day since I learned it ;)


artcore left a reply on Why Using : Let Self = This?

In arrow functions this is the surrounding context. No need to store it as self first.

thing.addEeventListener('click', e=>

thing.addEeventListener('click', function(e)

artcore left a reply on Signature Pad With Ajax

Try adding event.preventDefault(); in your saveButton callback. This will give the post request the chance to work as the default browser action is to act on the button click.

saveButton.addEventListener('click', function (event) {

if (signaturePad.isEmpty()) {
15 Mar
6 months ago

artcore left a reply on Best Way To Avoid Repeating Code In Controler

I'm enjoying lucid architecture to avoid duplicated code. Check it out at I'm not affiliated, just like the way it does things!

If you were to use an abstraction for the query filter, you'd still be duplicating that in your controllers ;)

artcore left a reply on Adding Values Into An Array.

If you need to show all months regardless of data then I would first build an array of months and loop over that + populate each (use a pre-filled array of data keyed on the month so you don't query the db in a loop). A month without data should be null, at least that is what highCharts expects so it can render a hole in the chart ;)