mrunknown

mrunknown

Member Since 4 Years Ago

at Student

Experience Points 66,170
Experience Level 14

3,830 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 640
Lessons
Completed
Best Reply Awards 4
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.

12 Jan
1 year ago

mrunknown left a reply on NodeJS File Upload

After many more hours and reading I have a solution, but from my research I figured out a lot of people struggle with this and Axios and Form Data doesn't have 100% compatibility

const concat = require("concat-stream")
const fd = new FormData()

fd.append("hello", "world")
fd.append("file", fs.createReadStream(file))
fd.pipe(concat(data => {
  axios.post("/hello", data, {
    headers: fd.getHeaders()
  })
}))

If you are going to use binary files (image etc) like most people then your need to encode the concat stream to binary buffer:

fd.pipe(concat({encoding: 'buffer'}, data => {

mrunknown started a new conversation NodeJS File Upload

Hi Everyone,

I've been stuck on this problem for a couple of days now and honestly feel like a moron for not figuring it out.

Basically I have a Electron app running with Vue. I want to send local files of app to my remote Laravel server, easy right? welp I thought so too.

I have a FormData object that I build up with random data, except for the entry which is a file that is a stream from Node's filesystem. I then send this using the Axios global variable this.$http, when sending this the file gets encapsulated as a string. Any ideas?

Upload Script:

syncFile (customer, file) {
        let endpoint = this.url + 'customers/' + customer + '/identification'

        let form = new FormData()
        form.append('foo', 'bar')
        form.append('bar', 'baz')
        form.append('baz', 'foo')
        form.append('file', fs.createReadStream(file.filePath))

        this.$http.post(endpoint, form, { headers: { 'Content-Type': `multipart/form-data; boundary=${form._boundary}`, 'Authorization': 'token' } }
        )
          .then(response => console.log(response))
          .catch(error => console.log(error.response))
      },

Payload:

'foo': 'bar',
'bar': 'baz',
'baz:' 'foo',
'file': '[object Object]'

Any help will really be appreciated.

  • mrunknown
28 Jan
2 years ago

mrunknown left a reply on [L5.4] Maximum Function Nesting And Segmentation Fault

@ARCANEDEV All projects run on Homestead and PHP v7.1.1.

mrunknown left a reply on [L5.4] Maximum Function Nesting And Segmentation Fault

@ARCANEDEV As previously stated I can't run any php artisan commands since it throws the Segmentation fault (core dumped) error and I have already tried composer dump-autoload with no success on any of the errors

mrunknown left a reply on [L5.4] Maximum Function Nesting And Segmentation Fault

@ARCANEDEV I set that to 2000, still failed.

Illuminate\Log\LogServiceProvider->configureHandler( ) in file .../LogServiceProvider.php:60 ran the whole time.

mrunknown started a new conversation [L5.4] Maximum Function Nesting And Segmentation Fault

Hello All,

I've updated my one project to Laravel 5.4 and been getting some weird errors I can't fix. I have a new project with a clean install of Laravel 5.4 with no problems.

All projects run on Homestead and PHP v7.1.1.

Errors I get:

  • When accessing via a web browser:

Fatal error: Maximum function nesting level of '512' reached, aborting! in /home/vagrant/Code/hirex/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 647

  • When using php artisan [don't even have to specify any commands]

Segmentation fault (core dumped)

Solutions I have tried

  • composer dumpautoload
  • composer clearcache and reinstall

Current composer.json (shortened for easier viewing)

{
  ...shortened...
  "require": {
    "php": ">=5.6.4",
    "laravel/framework": "5.4.*",
    "laravelcollective/html": "^5.4.0",
    "codecourse/notify": "^1.1",
    "davejamesmiller/laravel-breadcrumbs": "^3.0",
    "yajra/laravel-datatables-oracle": "^7.0",
    "barryvdh/laravel-debugbar": "^2.3"
  },
  "require-dev": {
    "fzaninotto/faker": "~1.4",
    "mockery/mockery": "0.9.*",
    "phpunit/phpunit": "~5.0",
    "symfony/css-selector": "3.1.*",
    "symfony/dom-crawler": "3.1.*"
  },
  "autoload": {
    "classmap": [
      "database"
    ],
    "psr-4": {
      "App\\": "app/"
    }
  },
  "autoload-dev": {
    "classmap": [
      "tests/TestCase.php"
    ]
  },
  "scripts": {
    "post-root-package-install": [
      "php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
      "php artisan key:generate"
    ],
    "post-install-cmd": [
      "Illuminate\\Foundation\\ComposerScripts::postInstall",
      "php artisan optimize"
    ],
    "post-update-cmd": [
      "Illuminate\\Foundation\\ComposerScripts::postUpdate",
      "php artisan optimize"
    ]
  },
  "config": {
    "preferred-install": "dist"
  }
}

Any help is really welcome. Thanks in advance, mrunknown.

30 Jul
2 years ago

mrunknown left a reply on Laravel Spark - Vuejs Third Party Components

Read the documentation for a start. There are great examples on the link you added.

27 Jul
2 years ago

mrunknown left a reply on Name For Project

@mstnorris I like orgy, has a nice meaning and is widely used already xD

25 Jul
2 years ago

mrunknown left a reply on Laravel Auth With Vue Or Any Other JS Framework

Okay so I figured it out, in your Kernel.php file you need to add the StartSession class to the api route

protected $middlewareGroups = [
    'web' => [
      \App\Http\Middleware\EncryptCookies::class,
      \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
      \Illuminate\Session\Middleware\StartSession::class,
      \Illuminate\View\Middleware\ShareErrorsFromSession::class,
      \App\Http\Middleware\VerifyCsrfToken::class,
    ],

    'api' => [
      'throttle:60,1',
      \App\Http\Middleware\EncryptCookies::class,
      \Illuminate\Session\Middleware\StartSession::class,
      \App\Http\Middleware\VerifyCsrfToken::class,
    ],
  ];

mrunknown left a reply on Laravel Auth With Vue Or Any Other JS Framework

I tried passing the csrf token through the header and I still get a 401. Unauthorized status. I check the CSRF token on my page and it matches the request send by my Vue resource

Route for hitting the API (just dummy routes for testing)

Route::group([ 'prefix' => 'api',  'middleware' => 'auth'], function () {
  Route::get('person', ['uses' => 'API\[email protected]', 'as' => 'api.person.index']);
});

App.js (Vue request)

Vue.http.headers.common['X-CSRF-TOKEN'] = document.querySelector('#token').getAttribute('value');

Vue.component('people', {
  ****SNIPPED****
      this.$http.get('../api/person').then((response) => {
          console.log(response);
      }, (response) => {
          // error callback
          console.log(response);
      });
  ****SNIPPED****
})

Blade view that has my CSRF token

<meta id="token" name="token" value="{{csrf_token()}}">
24 Jul
2 years ago

mrunknown started a new conversation Laravel Auth With Vue

Hello All,

I've been struggling to figure out how to configure Laravel's Auth with Vue. I would like to setup a basic "API" where Vue can make calls to the API, basically the same configuration as Taylor on the Echo demonstration (https://github.com/taylorotwell/echo-demo/). Its hard to reverse engineer the code since I don't have access to the Spark section of the code.

How would you make sure a user is authenticated on the normal web based access, but also through the vue calls to the API?

Thanks . mrunknown

11 Jul
3 years ago

mrunknown left a reply on October Cms Opinions

Its really great, stable and built with Laravel. Simple and easy to use, but you can easily add new features and improve the current system.

There are a lot of plugins / themes which are well built and maintained that can be used, but if you need something more custom you can easily create your own. Documentation is extensive and well written (same as Laravel) and there is a new Plugin builder which helps you to rapidly create a new plugin http://octobercms.com/plugin/rainlab-builder

mrunknown left a reply on Laravel & CSV - Save Data From A Form With Validation To CSV File.

You can easily just code a small csv export file, but if you want something more advanced try this library that generates excel documents https://github.com/Maatwebsite/Laravel-Excel

mrunknown left a reply on SQLSTATE[23000]: Integrity Constraint Violation: 1048

Error in your view:

name"email" and name"tasks"

Should be (typo)

name="email" and name="tasks"

mrunknown left a reply on SQLSTATE[23000]: Integrity Constraint Violation: 1048

In your controller do a dd($request) to see if the correct values from the form are posting

mrunknown left a reply on SQLSTATE[23000]: Integrity Constraint Violation: 1048

Why do you open your form twice? You also have a manual form in html, and you don't close the form at the end. Try this:

{!! Form::open(['action' => '[email protected]']) !!}
   <label for="email">Email:</label>
    <input type="text" name"email" id="email"><br>
    <label for="tasks">Tasks:</label>
    <input type="text" name"tasks" id="tasks"><br>
   
    <input type="hidden" name"_token" value="{!! csrf_token() !!}">
   
    <input type="submit" name"submit" id="Create">
{!! Form::close() !!}

mrunknown left a reply on SQLSTATE[23000]: Integrity Constraint Violation: 1048

Change your controller:

public function store(Request $request)
{       
  $user = new User;    //Model
  $user->email= $request->email;
  $user->tasks= $request->tasks;
  $user -> save();      
  return ("added");
}

Thus calling the values of the email and tasks field through the request of the form

08 Jun
3 years ago

mrunknown left a reply on Validation - Other Field Has Value

@veve286 that checks to see if the product.sku is present and it will be since its in the form, but it won't necessarily have a value. This is why I want it to be present and have a value

mrunknown left a reply on Validation - Other Field Has Value

@veve286 That is not 100% what I am looking for, but close to it

'sometimes' - checks only if the current field is present 'required_with' - checks only if another field is present

I want something like required_with, but it should not check if the field is present, but if the field has any value in it.

For example I have an array of product..sku and product..description, description should be required if and only if sku is present and has an value thus not empty

07 Jun
3 years ago

mrunknown left a reply on Best Way To Backup Multiple Databases To Dropbox

As previously mentioned just mysqldump it on a cron job and then you can easily ftp/dropbox/aws store the file

I run a nightly dump with the following script

mysqldump --opt -Q dbname | gzip > "/home/username/db/db_backup_$(date +\%Y_\%m_\%d).sql.gz"

mrunknown left a reply on Best Way To Plan/start Laravel Project?

@davidlapham, I personally don't use repositories that often since most of my applications are small CRUD-based ones so its easier and faster for me to just use basic models

mrunknown left a reply on Validation - Other Field Has Value

I have the following validation scaffolding setup, but for some reason it only validates singles attributes and not arrays of attributes. For testing purposes I made the validation fail and it does for the single value of customer_id, but not for product_1_sku or product_2_sku, any ideas?

AppServiceProvider.php

public function boot()
{
  Validator::extend('required_with_value', 'HireX\Http\[email protected]');
}

CustomValidator.php

class CustomValidator {
  public function validateRequiredWithValue($attribute, $value, $parameters, $validator)
  {
    return false; // Testing purposes
  }
}

RentalController.php

$this->validate($request, [
  'customer.id_number'    => 'required|required_with_value:product.*.sku', // Single attribute testing works
  'product.*.description' => 'required_with_value:product.*.sku', // Multiple attribute testing fails
]);

mrunknown left a reply on Best Way To Plan/start Laravel Project?

I usually follow these steps:

  1. DB Design
  2. Model with DB migrations
  3. Controllers for each models and routing
  4. Views
  5. UI/UX improvements
  6. Testing
  7. Repeat till project is completed and everything is working correctly

mrunknown started a new conversation Validation - Other Field Has Value

Hello Laracasters,

I am trying to write custom validation which states that a field is required if another field exists and has a value in. Currently Laravel provides the required_with rule, but that only checks if a field exists and not if it has a value.

Is it possible to call the required_with rule in the custom validation rule and then add addition validation to check if the field has value or should everything be coded from scratch?

Thanks in advance ..mrunknown

08 Apr
3 years ago

mrunknown left a reply on How To Get Request Input In Route Closure?

@dengdeng That should work in theory, you can also try $request->name; instead of $request->input('name');

04 Apr
3 years ago
03 Apr
3 years ago

mrunknown started a new conversation Dynamic Form Generation / Binding

To all casters,

I currently have a form that generates invoices, with each "product line" generated from a AJAX request to a Laravel method returning a rendered view. So after you fill in a product line it automatically generates a new line using this AJAX request, generation is working as well as validation of those lines.

The logic error I am getting is that after validation all lines are lost except the first(original) line since the form only generates 1 line at the start and the rest with the AJAX request. The original line still has its values (form-model-binding), but after adding the rest via the same AJAX request the data is not there since it binds at form creation at those field aren't there to bind.

How would I still have a dynamic form that generates new lines, but keep the lines (and values) after validation... This is also going to be a problem with the editing of the invoice.

Thanks in advance. .. mrunknown

PS - Here are some form fields as example

product[lineNumber][sku]
product[lineNumber][description]
product[lineNumber][price]

lineNumber is a variable of the current product line

05 Mar
3 years ago

mrunknown left a reply on Creating Views: Blade Or Vue?

Both ways would work fine. Basically think of the strain it will cause on the server/client side. What do you prefer and what would be easier for you to code

mrunknown left a reply on Mobile Site First Time To Load Is Taking Too Long?

Have you tried Chrome Developers tool? Then you can set the device mode to mobile and throttle the speed to something like 4G / 3G to see how it compares.

04 Mar
3 years ago

mrunknown left a reply on Check If Value Is Set Already

Welp, I don't think you can getting it shorter than that without using ternary operators, but that is most likely going to defeat the point

03 Mar
3 years ago

mrunknown left a reply on Best Practice: Rental Vs Once Off Transactions

Lets say a user rents the product from the departure date to the rental date, but also wants to "buy"/rent another add on that works on quantity and NOT rental duration. The toggle on the side is to change between rental and selling. Row 2 and 3 are the same (sell) products, whilst row 1 is for rental.

I think I might split it up. Will clear up a couple of things and make it cleaner and easier to code. Also is there a jquery plugin that I can use to select a date range? Then I don't need to split up departure and return date

02 Mar
3 years ago

mrunknown left a reply on Laravel Socialite User Update

I misspoke when I wrote this "it will auto update".

Socialite stores a facebook_user_id linked to Facebook. So if a user logs in, data regarding the user IS NOT retrieved from the database, BUT the system gets the data directly from Facebook using that facebook_user_id linked to Facebook from your database.

mrunknown left a reply on Laravel Socialite User Update

AFAIK Socialite doesn't update a user's social information. Socialite links the user in your system to a social network such as Facebook. The only data that is stored is the link between your system and the social network. So if the user changes their information on a social network it will auto update since Socialite gathers the information directly from the social network and not from your database. Basically there is no quick way of disabling this feature.

mrunknown left a reply on Best Practice: Rental Vs Once Off Transactions

The current DB has a table Transactions which hold each transaction within an Invoice.

Rental/products share most attributes, except the following:

  • Rental has: return_date and departure_date
  • Product has: quantity So I think I will just have a field called rented (in the Transactions table) and rentable (in the Products table)

Here is a screenshot of the current interface. I really don't like it, but don't know what to change. alt text

Currently if you enter a new field the system will Ajax a laravel function and return a view of a new field. Then you can toggle between rent/sell. Top field is a rented product. Bottom 2 is sold products

01 Mar
3 years ago

mrunknown left a reply on Best Practice: Rental Vs Once Off Transactions

@Reached Will send it through when I get home. Any ideas for the database?

mrunknown started a new conversation Best Practice: Rental Vs Once Off Transactions

Hello All,

I need some suggestions/best practices advice for a coding problem I've been having, not so much code, but ideas. I am creating a rental system which rents out products (create invoices and all needed) on a daily basis, which is quite simple.

Now I want to extend the system to not only allow product rentals, but also sell products. What do you guys think is the best way of setting up the database? Should each transaction be split into rental/selling or should it be in the same table just identified by an attribute (showing what type of transaction it is)? Then in regards to how the UI/UX should work. What is the best method for providing products to be sold and rented on the same invoice whilst making making it look clean and simple? The current format I am using looks confusing and is just a lot of code hacked together to make it work. I am looking for more an elegant method.

Thanks in advance

  • mrunknown

mrunknown left a reply on SQLSTATE[42s22]: Column Not Found: 1054

This forum uses "Markdown with GitHub-flavored code blocks" as stated below each thread. Here is a link for syntax and highlighting code https://help.github.com/articles/creating-and-highlighting-code-blocks/

29 Feb
3 years ago

mrunknown left a reply on SQLSTATE[42s22]: Column Not Found: 1054

This

+$test->partner_an_education_institution = 1;

Should be this (spelling mistake) [always find to see if everything matches]

+$test->partner_an_educational_institution = 1;

mrunknown left a reply on Error While Validation Inside Controller

Your validation method looks fine, try adding use App\Http\Requests; as shown in the example

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

mrunknown left a reply on SQLSTATE[42s22]: Column Not Found: 1054

Please fix your post. Most of it is unreadable.

mrunknown left a reply on Using Scss Within Public

Add the .scss file into your resources/assets/sass directory then add them to your gulpfile.js

var elixir = require('laravel-elixir');

elixir.config.sourcemaps = false;

elixir(function(mix) {
    mix.sass([
        'bootstrap.scss',
        'global/components.scss',
        'global/plugins.scss',
        'layouts/layout/layout.scss',
        'layouts/layout/themes/darkblue.scss',
        'custom.scss',
    ]);
});

Then just run gulp or gulp watch from the command line. It will output a css file in your public directory

See: https://laravel.com/docs/5.2/elixir

mrunknown left a reply on Code Mangement

After more than a month of busyness and chaos I have finally time to reply.

I took everyone's suggestions and worked through them one by one trying to find the pros / cons of the solution. Here are my findings: BitBucket - I will agree with everyone in that Github is better, but for small-medium solutions I love BitBucket. With unlimited free repos its amazing to use and makes my life a lot more easier. GitHub - As stated above its amazing , but can't afford the private repos and don't want to use my educational account. PHPStorm - After using Sublime/Atom for so long I got use to the simplicity. PHPStorm is just to much features for me. I like to manage my own stuff. (Still use Notepad++ and Atom to program C++/Java) VisualSVN / GitLab / Gogs - I tested, but will not try and host my own stuff for redundancy reasons. GitLab.com - I did some small tests with it since I am already satisfied with BitBucket. Everything works and I had no problem with speed as previous mentioned, but too much of a hassle to switch from BitBucket.

26 Jan
3 years ago

mrunknown left a reply on Code Mangement

@bashy @zachleigh going to try both BitBucket and GitLab

@RokSiEu I strive in being organized with my code, but storing multiple projects in 1 repository seems counterproductive . I might use VisualSVN if I have no other solution. Would you recommend using a IDE such as PHPStorm above text-editors such as Atom and Sublime?

mrunknown left a reply on Code Mangement

@RokSiEu I am currently between Sublime and Atom as my code editors, don't like full-fledged IDE's so much. Maybe gonna try PHPStorm since a lot of Laravel/PHP developers are using it.

I did try BitBucket which is nice, but I need a lot more than 5 private repositories.

mrunknown started a new conversation Code Mangement

Hello To All Coders,

I am currently studying and doing freelance web development work, but I've been struggling storing and managing my code that I develop for both my freelancing work as well as my university coding samples.

Currently I am just storing all my code inside my Google Drive folder and manage versions by creating different version folders, but as some of you might know storing all the vendor, node_modules, etc. can take a long time to sync.

I also use GitHub to store some of my open-source project, but I am looking for software to help me manage and store my code privately, both locally and on the cloud.

What free(cheap) software/services are available to manage code with version control?

Thanks in advance mrunknown

P.S. Any other tips for both code management and freelancing will be appreciated.