artcore

artcore

Member Since 1 Year Ago

Software Engineer at Self employed

Experience Points 5,570
Experience Level 2

4,430 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
Lessons
Completed
Best Reply Awards 6
Best Reply
Awards
  • 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

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    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.

22 May
3 days 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
1 week 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 (https://designpatternsphp.readthedocs.io/en/latest/README.html) 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
2 weeks ago

artcore left a reply on Load Data For Month Selected

I've been using https://bootstrap-table.com/ in combination with http://www.daterangepicker.com/ 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
3 weeks 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 https://parceljs.org/getting_started.html 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 weeks ago

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

Take a look at this https://github.com/TomLingham/Laravel-Searchy

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
1 month 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
1 month 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
1 month ago

artcore left a reply on Laravel Blade And Javascript

Wrap it inside a dom ready event?

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

   $('.date').datepicker({  

     format: 'mm-dd-yyyy'

   });

});

artcore left a reply on Select With Over 10.000 Records

@neflictus This library works nicely with jQuery: https://select2.org/data-sources/ajax 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.

$('#mySelect2').select2({
  ajax: {
    url: 'https://api.github.com/search/repositories',
    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
1 month 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. https://export.highcharts.com/

11 Apr
1 month 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

@extends('catalog::layout.app')
@section('title', 'Catalog Image Form')
@section('stylesheets')
  <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">
@endsection
@section('content')
  <div class="container">

    <div class="card mt-5">
      <div class="card-header">
        <h5>
          <i class="fa fa-pencil position-left"></i>
          <span class="text-semibold">{{ is_object($data) ? 'Edit' : 'Add' }}</span> Image:
        </h5>
        <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>
          </a>
        </div>
      </div>
    </div>

    <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('image.store') }}"
              enctype="multipart/form-data"
              class="steps-validation">

          @if(is_object($data))
            {{ method_field('PUT') }}
          @endif

          {{ 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>

              <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"
                         name="image[file]"
                         class="custom-file-input form-control"
                         id="location">
                  <input type="hidden"
                         name="image[location]"
                         value="{{ $data->location ?? old('image.location') }}">
                  <input type="hidden"
                         name="image[crop]"
                         value="">
                </div>
              </div>

              <div class="form-group" data-select="link" data-collection="lookup">
                <input type="text"
                       placeholder="add link"
                       class="form-control">
              </div>
              <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>
                  @if(is_object($data))
                    @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 }}">
                      </li>
                    @endforeach
                  @endif
                </ul>
              </div>

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

            <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>

              <div id="preview">
                <img src="{{ isset($data->location)
              ? asset('public/assets/catalog/img/item/'.$data->location)
              : 'https://via.placeholder.com/400x600.png?text=Empty' }}" alt="">
              </div>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
@endsection
@section('scripts')
  <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 =>
                              {
                                set();
                              }
        });

      image.addEventListener('cropend', (event) =>
      {
        set();
      });
      image.addEventListener('cropmove', (event) =>
      {
        set();
      });
      image.addEventListener('zoom', (event) =>
      {
        set();
      });
    };

    crop();

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

      event.target.previousElementSibling.innerText = fileName;
      event.target.nextElementSibling.value = fileName;

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

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

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

      switch (method)
      {
        case 'reset':
          cropper.reset();
          break;
        case 'enable':
          cropper.enable();
          break;
        case 'disable':
          cropper.disable();
          break;
      }

    }, false);
  </script>
  <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)
      .template(suggest,
        {
          action: action,
          title:  ['title', 'item']
        });
  </script>
@endsection

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)
  {
    try
    {
      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));

        $filesystem->put(
          config('catalog.disks.archive.folder') . $fileName, $file);

        return $fileName;
      }
    }
    catch (\Exception $e)
    {
      logger($e->getTraceAsString());
    }
  }
}

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 https://github.com/fengyuanchen/cropperjs I let the user fit the image inside a fixed width box - multiple croppers are supported. There's a related vue project here https://github.com/Agontuk/vue-cropperjs but I'm using the vanilla version myself - I have no experience with vue

08 Apr
1 month 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.

https://stackoverflow.com/questions/42871136/dispatch-function-in-redux-react https://redux.js.org/api/store#dispatchaction

03 Apr
1 month 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
1 month 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
1 month 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 e.target to perform the action once. You still need to stop the bubbling up though.

24 Mar
2 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 ;)

https://laravel.com/docs/5.8/validation

22 Mar
2 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
2 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
2 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 ratings.one

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

17 Mar
2 months ago

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

Have a look at https://select2.org/data-sources/ajax 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
2 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 ;)

Cheers

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=>
    {
        console.log(this);
    });

thing.addEeventListener('click', function(e)
    {
        console.log(this);
    });

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) {

    event.preventDefault();
        
if (signaturePad.isEmpty()) {
15 Mar
2 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 https://github.com/lucid-architecture/laravel 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 ;)

11 Mar
2 months ago

artcore left a reply on AJAX GET REQUEST USING LARAVEL

@ARUNAVA007 - ``` if(request()->wantsJson()) // or request()->isXmlHttpRequest() depending on your headers return response()->json([]); else return view()

in reply to using the same route for a view and an xmlHttpRequest
10 Mar
2 months ago

artcore left a reply on How To Replace Highcharts To Reduce The Number Of DOM Nodes?

I'm using highcharts too and remembered they added a speed boost to version 6. https://www.highcharts.com/blog/tutorials/highcharts-high-performance-boost-module/

Hope it helps! Btw I upgraded from version 5 just by dropping in v6, no issues.

07 Mar
2 months ago

artcore left a reply on Your Thoughts About Writing Everything In Modules/packages?

My pleasure! Laravel is making development too awesome especially since it doesn't force you to work their way

06 Mar
2 months ago

artcore left a reply on Your Thoughts About Writing Everything In Modules/packages?

I'm doing the same thing, the only way to make portable apps. As a tip, if you don't want a dependency like laravel-modules you can create your own composer.json in your folder structure that contains the whole app and add it to laravel's composer with a symlink path

Here's an example of a personal package composer.json

{
  "name": "extend/utility",
  "version": "1.0.0.1",
  "description": "Utility package Laravel",
  "type": "library",
  "license": "MIT",
  "authors": [
    {
      "name": "Albert",
      "email": ""
    }
  ],
  "autoload": {
    "psr-4": {
      "Extend\Utility\": "/"
    }
  },
  "extra": {
    "laravel": {
      "providers": [
        "Extend\Utility\Foundation\ServiceProvider"
      ],
      "aliases": {}
    }
  },
  "minimum-stability": "dev",
  "prefer-stable": true
}

and the laravel composer entries

{
  "name": "laravel/laravel",
  "type": "project",
  "description": "The Laravel Framework.",
  "keywords": [
    "framework",
    "laravel"
  ],
  "license": "MIT",
  "require": {
    "php": "^7.1.3",
    "fideloper/proxy": "^4.0",
    "laravel/framework": "5.7.*",
    "extend/utility": "1.0.*",
    "ext-pdo": "*"
  },
  "require-dev": {
    "beyondcode/laravel-dump-server": "^1.0",
    "filp/whoops": "^2.0",
    "fzaninotto/faker": "^1.4",
    "mockery/mockery": "^1.0",
    "nunomaduro/collision": "^2.0",
    "phpunit/phpunit": "^7.0"
  },
  "config": {
    "optimize-autoloader": true,
    "preferred-install": "dist",
    "sort-packages": true
  },
  "extra": {
    "laravel": {
      "dont-discover": []
    }
  },
  "autoload": {
    "psr-4": {
      "App\": "app/"
    },
    "classmap": [
      "database/seeds",
      "database/factories"
    ]
  },
  "autoload-dev": {
    "psr-4": {
      "Tests\": "tests/"
    }
  },
  "minimum-stability": "dev",
  "prefer-stable": true,
  "scripts": {
    "post-autoload-dump": [
      "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
      "@php artisan package:discover --ansi"
    ],
    "post-root-package-install": [
      "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
      "@php artisan key:generate --ansi"
    ]
  },
  "repositories": [
    {
      "type": "path",
      "url": "./Extend/Utility/"
    }
  ]
}

update composer and you're good to go ;)

artcore left a reply on I'm Nervous That My App's Security Has Flaws. Asking For Feedback.

you're welcome! and I learned that tabs in this forum don't get parsed ;)

artcore left a reply on I'm Nervous That My App's Security Has Flaws. Asking For Feedback.

Your Laravel setup sounds good to me. Did you also harden the server itself? Thinking of no remote db access, bind to 127.0.0.1 anti-ddos hardware, datacenter quality mod_security suhosin firewall, auto-block failed logins with admin email? no directory browsing ftp/ssh restrictions dnssec backup remotely :)

I would also log successful logins and check for anomalies like IP changes

05 Mar
2 months ago

artcore left a reply on Login Expires And Shows Private Data

Middleware for easy reuse or in the controller first for a quick test

return response()
    ->view('your view')
    ->header('Cache-Control', 'no-cache,must-revalidate');

I hope it works. Maybe the browser first has to 'see' it fresh with the cache control header before it can decide to not cache it next time? I never experienced what you got in my login pages though

artcore left a reply on Login Expires And Shows Private Data

How about adding a header to the response? https://laravel.com/docs/5.7/responses#attaching-headers-to-responses

header('Cache-Control', 'no-cache, must-revalidate')
03 Mar
2 months ago

artcore left a reply on Collection Min / Max Takes Very Long - Why?

It looks like you're querying the db in a nested loop. What I usually do is prepare an array (of objects) with the id as index. In the loop you can then lookup the object by the key. I'm not using eloquent or the query builder of Laravel so I can't give you an example but it's called eager loading. I'm using a decorated pdo class where I can use fetchUnique which retrieves the data indexed by the first column. Very handy

02 Mar
2 months ago

artcore started a new conversation Deferred Provider Not Merging Config

I have a package added to the service providers as deferred and it doesn't merge the config.

protected $defer = true;
 $this->mergeConfigFrom(
        __DIR__.'/path/to/config/something.php', 'something'
    );

It works fine if not deferred. I prefer not having it loaded by default. Am I missing something?

25 Feb
3 months ago

artcore left a reply on How To Use Multi Select Box On Dynamically Add Fields & Jquery .length Function Incorrectly

Future elements have no event listener so either add a listener on the parent table or - easiest - listen on the document like this:

$(document).on('click','.remove',function () {
15 Feb
3 months ago

artcore left a reply on Suggestion On Database Design For Storing Product With Bulk Purchase Price

Sometimes you just need to go with an idea even if you suspect it'll be changed down the road. There's no right or wrong but you can save yourself some time by identifying when you need to extract functionality to it's own entity. Makes it flexible and reusable ;) So definitely go for it and see where you end up.

Cheers!

artcore left a reply on Suggestion On Database Design For Storing Product With Bulk Purchase Price

Literally a conditions table with rule and amount and probably a condition_description with multilingual text to display during cart totals updates and as incentive on the products.

The discount will be checked in the cart or checkout page. So after the add-to-cart action you would check the conditions. If discounts && quantity is a rule, than apply to each product where quantity meets the condition. And then update the pricing/totals accordingly. Nice bonus is the discount description: quantity >30 = 20% discount or something.

It's a lot of extra code so you may not need this elaborate option if you have the same discounts always, but I reckon your client would invent other incentives in the future ;)

I've worked with a few ecommerce solutions that have this implemented, you can always check how it's done in existing webshops. Reinventing the wheel is educational but takes time...

artcore left a reply on Suggestion On Database Design For Storing Product With Bulk Purchase Price

A more flexible solution would be to have a discounts table and a discount_conditions where in this case quantity triggers the price - discount

e.g. condition = quantity, rule >30, discount = 2

Multiple prices for a product should be in my opinion for different currencies to avoid weird rounding

13 Feb
3 months ago

artcore left a reply on What Is The Best Js Framework To Use With Laravel

I've been weaning myself off of jQuery for my latest project in favor of pure es6 modules and fetch() for ajax requests. For me it's a relief to not be dependent on a framework anymore. Plus, you learn the actual workings of js in stead of being used to a facade.

Lastly, a personal note and correct me if I'm wrong - I just saw a few examples. Angular and Vue have what I call inline code which looks really messy. Like similar to an onclick= on an element. I prefer to have everything in a separate js file.

07 Feb
3 months ago

artcore left a reply on How To Introduce Lucid Architecture Into An Existing Project?

You'll be rewriting the whole thing basically so my advice is to start a new project and bring in the parts one at a time. You can ask the lucid-arch creator and other users here also: https://lucid-arch.slack.com

03 Feb
3 months ago

artcore left a reply on Laravel CSV To MySql

Look into the SplFileObject and loop by chunks setting start+end pointers on each iteration. I recently did this with the geonames cities database with over 11MLN records

Here's a snippet for usage in the console

public function handle()
{
  $this->CSV->delimiter = ',';

  $file = new \SplFileObject(__DIR__ . "/../../database/seeds/$this->source", 'r');

  $file->seek(PHP_INT_MAX);
  $total = $file->key();
  $file->rewind();

  $data = $this->CSV->read($file, 0, 100000);

//insert into db
  dd($data);
}


/**
 * @param \SplFileObject $file
 * @param $from
 * @param $to
 * @return array
 */
public function read(\SplFileObject $file, $from, $to)
{
  $file
    ->setFlags(\SplFileObject::READ_CSV | \SplFileObject::READ_AHEAD | \SplFileObject::SKIP_EMPTY | \SplFileObject::DROP_NEW_LINE);
  $file
    ->setCsvControl($this->delimiter);

  $file->seek($from);

  $header = $this->header ?: $file->current();

  if (!$this->header)
    $file->next();

  $data = [];

  while (!$file->eof() && $file->key() <= $to)
  {
    $arr = [];
    foreach ($header as $i => $col)
    {
      $col = trim($col);

      if ($col)
        $arr[$col] = trim($file->current()[$i]) ?: null;
    }
    $data[] = $arr;

    $file->next();
  }

  return $data;
}