artcore

artcore

Software Engineer at Self employed

Member Since 1 Year Ago

Experience Points
5,950
Total
Experience

4,050 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-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

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

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

Level 2
5,950 XP
Oct
03
2 weeks ago
Activity icon

Replied to Please Could You All Advice Me

I did it this way... While having a day job I started writing and selling extensions for a number of cms's and thus learning php,sql,css the whole stack. Eventually that landed bigger jobs as site owners always need trustworthy and capable developers. Now I've been self-employed for about 3 years in a row and quit the day job. It did take about 3 years to be fully self supporting though. I'm almost 50 so it's never too late to start something new ;)

Sep
21
4 weeks ago
Activity icon

Replied to How To Know If A Method Is Called From Blade Or Elsewhere

Unless I'm missing something...the obvious context for me would be the user locale. Could be a cookie or session. Just like setting language, currency and so on, set the calendar type based on the user

Sep
13
1 month ago
Activity icon

Replied to 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
   */
  extract($this->data);

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


  $main = array_shift($messages);


  $message
   ->setSubject($subject)
   ->setFrom($from)
   ->setBody($main->content, $main->type);


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

  if (isset($headers))
   $this->run(AddHeadersJob::class,
    [
     'headers' => $headers,
     'message' => &$message,
    ]);


  if (isset($to))
   $message->setTo($to);

  if (isset($cc))
   $message->setCc($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);
   else
    $header->setValue($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';

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

  return $this->message;
 }
}

send

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);
  }
}
Aug
20
2 months ago
Activity icon

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

Aug
19
2 months ago
Activity icon

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
     */
    $message->setSubject($mailable->subject);
    $body = $message->getBody();

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

    $message->setTo([$subscriber->email]);
  });
Aug
08
2 months ago
Activity icon

Replied to 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;
      }
      else
        $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
      ->collect('*')
      ->with('products')
      ->where('locale', Condition::equals(app()->getLocale()))
      ->orderBy('id', 'ASC')
      ->fetch('fetchObjects');

     $results = $collection->generateAll($results, '0', 'parent_id');
  }
}
Aug
03
2 months ago
Activity icon

Replied to 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 ;)

Jul
21
2 months ago
Activity icon

Replied to Best Way To Secure Healthcare Data In DB

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

Jul
09
3 months ago
Activity icon

Replied to 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, ...online(website, 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.

Jun
22
3 months ago
Activity icon

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

https://github.com/lucid-architecture/laravel

Jun
11
4 months ago
Activity icon

Replied to 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...

Activity icon

Replied to New CSS Only Updates When Hard-refreshing(ctrl + F5)

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

Jun
03
4 months ago
Activity icon

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

Activity icon

Replied to Design Patterns

Hi Bobby,

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

May
30
4 months ago
Activity icon

Replied to 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.

May
28
4 months ago
Activity icon

Replied to 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
Activity icon

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

suhosin.post.max_array_index_length = 256;
suhosin.post.max_name_length = 256;
suhosin.post.max_array_depth = 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...

May
27
4 months ago
Activity icon

Replied to Access DigitalOcean From Windows With SSH

Cool. It seems vsc has an sql extension: https://marketplace.visualstudio.com/items?itemName=formulahendry.vscode-mysql

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

Activity icon

Replied to Access DigitalOcean From Windows With SSH

Hi,

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

May
22
4 months ago
Activity icon

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

May
18
5 months ago
Activity icon

Replied to 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 ;)

May
08
5 months ago
Activity icon

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

May
03
5 months ago
Activity icon

Replied to 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
    }
  }
}
Activity icon

Replied to 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.

Apr
26
5 months ago
Activity icon

Replied to 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.

Apr
23
5 months ago
Activity icon

Replied to 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)