Nash

Experience

60,470

62 Best Reply Awards

  • Member Since 2 Years Ago
  • 187 Lessons Completed
  • 25 Favorites

22nd June, 2018

Nash left a reply on Markdown VS HTML + Purifier? Please Help Me Decide! • 22 hours ago

Yes, that seems to be the case...as long as whatever package you use can remove unwanted HTML and scripts.

Nash left a reply on On Local Environment I Would Run Php Artisan Storage:link To Create A Symlink, But I Cannot Run It On Server Due To The Hosting Plan Limitation. Any Other Way To Create The Symlink? I Have No Shell Access :( • 22 hours ago

You could try to execute the Artisan command from a route or controller, e.g. something like:

Route::get('/storage-link', function () {
    $exitCode = \Artisan::call('storage:link');
});

https://laravel.com/docs/5.6/artisan#programmatically-executing-commands

Nash left a reply on Markdown VS HTML + Purifier? Please Help Me Decide! • 23 hours ago

HTML:

  1. Purifier will remove scripts and unwanted attributes (e.g. onhover) if configured to do so.

  2. You can embed YouTube videos, you just need to configure the white list to allow iframes. You can even specify the allowed URL's (e.g. allow embeds from YouTube and Vimeo but nothing else).

Markdown is just plain text so it doesn't really need an actual "editor" (front end plugin)? You should use Purifier in any case, since your Markdown will be converted into HTML when displayed on your site.

21st June, 2018

Nash left a reply on Routing • 1 day ago

What does your routes file and views look like so far?

20th June, 2018

Nash left a reply on How To Determine A Framework? • 2 days ago

Well a framework is more like a skeleton or something that provides a control flow for your entire application, whereas a library is just a collection of specific functionality to use within your application.

The key difference between a library and a framework is "Inversion of Control". When you call a method from a library, you are in control. But with a framework, the control is inverted: the framework calls you.

https://www.programcreek.com/2011/09/what-is-the-difference-between-a-java-library-and-a-framework

19th June, 2018

Nash left a reply on Search Parts In The Database Instead Of The Whole Value. • 4 days ago

In its simplest form, this can be achieved using the SQL LIKE operator, e.g.

$search = request('search');
$results = Post::where('title' , 'LIKE', "%$search%")->get();

For more advanced searches, you may want to consider something like Laravel Scout and Algolia.

14th June, 2018

Nash left a reply on Str_slug Strips Everything After Ampersand & Hash Tag • 1 week ago

@Cronix Not necessarily run a query string through the function, but rather avoid that it happens by mistake...and to make sure that it simply isn't possible, (in case someone actually does have a link or something in the string).

Something like "Haha, I love hashtags #smile" could make the page jump to an anchor with same ID (id="smile").

Nash left a reply on Str_slug Strips Everything After Ampersand & Hash Tag • 1 week ago

It's probably meant to remove/avoid query strings and anchors in the URL, e.g.

  • example.com?order=name&sort=asc
  • example.com#tab2

Nash left a reply on Problem Creating A Project • 1 week ago

How are you trying to install it?

Are you using composer like the documentation says:

composer create-project --prefer-dist laravel/laravel your-project-name

https://laravel.com/docs/5.6/installation

11th June, 2018

Nash left a reply on OpenSSL SSL_read: SSL_ERROR_SYSCALL, Errno 10054 • 1 week ago

@Nikki Ok, good. Please mark your question as solved in case someone else runs into this.

10th June, 2018

Nash left a reply on Laravel 4.2 Form • 1 week ago

You mean a form wizard?

Well there's this one for VueJS: https://cristijora.github.io/vue-form-wizard

...and here are 6 others for jQuery: https://www.sitepoint.com/jquery-form-wizard-plugins

Nash left a reply on Laravel 4.2 Form • 1 week ago

Nash left a reply on Undefined Property: Illuminate\Database\Eloquent\Relations\HasMany::$id • 1 week ago

What are you trying to create and why does it need a school ID?

If you want a specific school, you need to do something like:

auth()->user()->schools()->where('something', '123')->first();

Nash left a reply on Undefined Property: Illuminate\Database\Eloquent\Relations\HasMany::$id • 1 week ago

The user has many schools. You are trying to get a single ID from a collection of many SchoolsList objects. You need to iterate the collection, for example:

@foreach(auth()->user()->schools as $school)
    <input type="hidden" value="{{ $school->id }}" name="school_id">
@endforeach

See https://laravel.com/docs/5.6/eloquent-relationships#one-to-many

9th June, 2018

Nash left a reply on Recommendations For Databases In Laravel? • 1 week ago

Check out MySQL 101

Nash left a reply on Installation Of NPM Broke The Global Installation Of Laravel • 1 week ago

You probably need to add composer's vendor/bin directory in your PATH: https://stackoverflow.com/questions/26451187/how-to-install-laravel-via-laravel-installer-on-windows/36216160#36216160

But you can just as easily use composer to create a new Laravel project (no need to use the Laravel installer): composer create-project --prefer-dist laravel/laravel name-of-your-project

https://laravel.com/docs/5.6/installation

Nash left a reply on Login And Register Forms On One Page (one View File) • 1 week ago

You can use named error bags for this.

Nash left a reply on Initial Site Deployment Fails • 2 weeks ago

The main page for your site/app in Forge should show have a "View Latest Deployment Log" link with the full log. Recent events and logs are also shown on the [https://forge.laravel.com/servers](servers page).

Nash left a reply on How To Access Error Log For A Production Laravel Cite On Forge? • 2 weeks ago

Your error log is likely in /var/log/nginx/your-site-name.tld-error.log.

The Nginx configuration file under Sites -> Your Site Name -> Files (button in the footer) -> Edit Nginx Configuration in Forge shows this location.

5th June, 2018

Nash left a reply on OpenSSL SSL_read: SSL_ERROR_SYSCALL, Errno 10054 • 2 weeks ago

Hmm...besides what you have already tried, some suggestions are about the connection, ISP and enabling hardware virtualization in BIOS.

Any luck if you retry a few times with a different Internet connection?

4th June, 2018

Nash left a reply on Show Undefined Variable In Edit Code • 2 weeks ago

Like the error message says, $department is not defined in allDepartment.blade.php. Where is this variable coming from? Also, it's probably an object, not an array.

I assume you are trying to do something like this?

@foreach($departments as $department)
    <a href="{{ action('[email protected]', $department->depid) }}" class="" data-toggle="tooltip" title="Edit">Edit</a>
@endforeach

Nash left a reply on Do You Trust Filling Old User Input On A Form? • 2 weeks ago

I see what you mean now, good point.

For the array, you could do a check like is_array(old('array-input')). You could also typecast old input, e.g. (string) old('username').

As long as you have back end validation, the input should never reach your database or business logic (unless you have business logic in your views, which, you should't) regardless of how it looks like in the front end. Everything in the front end can be modified by the user anyways.

Nash left a reply on Do You Trust Filling Old User Input On A Form? • 2 weeks ago

  • You can't pre-populate a file input (type="file)

  • "username" is not a valid input type. You probably mean type="text".

  • You should always have back end validation to make sure it's the correct type when there's user input involved.

Nash left a reply on Install Sass • 2 weeks ago

Maybe it's already installed then? See if you can uninstall and reinstall the package.

Also, note this:

This package has taken over the package name “Sass”

If you updated this package from the original Sass package you might notice SCSS files are highlighted with the Sass syntax, to solve this issue, please open any .scss file and reset its highlighting syntax with the “Open all with current extension as…” option.

https://packagecontrol.io/packages/Sass

Nash left a reply on Alert Alert-success Not Showing • 2 weeks ago

this is not session, this is just a variable and it will be always there.

@Sergiu17 Actually, when used with redirect(), with flashes data to the session: https://laravel.com/docs/5.6/responses#redirecting-with-flashed-session-data

Try naming it something other than "response", e.g. "status". If that doesn't work, then there must be something else wrong. Are you sure the home.blade.php view is actually loaded for the / route?

// In your Controller
return redirect('/')->with('status', 'Hello!');

// In your View
@if (session('status'))
    <div class="alert alert-success">
        {{ session('status') }}
    </div>
@endif

Nash left a reply on How To Return 0 Or Any Value When There Is No Records In Table Laravel? • 2 weeks ago

You can use count() to get the number of records.

if (! Purchase_details::count()) {
    // no records
}

You can also use exists() or doesntExist().

https://laravel.com/docs/5.6/queries#aggregates

Nash left a reply on Install Sass • 2 weeks ago

I can find it in package control just fine. Make sure you are using the latest version of Sublime Text 3.

3rd June, 2018

Nash left a reply on $this->user_id Not Executing • 2 weeks ago

Since Laravel 5.3, you can't get the auth user/id or any other session variables in the constructor because the middleware has not run yet. See the docs: https://laravel.com/docs/5.3/upgrade#5.3-session-in-constructors

You could do it like this:

public function __construct()
    {
        $this->middleware(function ($request, $next) {
            $this->user = Auth::user();

            return $next($request);
        });
    }

But like @Snapey said, do you really need to when there are so many other ways to get the auth user/id?

1st June, 2018

Nash left a reply on 404 Not Found In Views Subfolders • 3 weeks ago

when I deploy the site to the webserver and dump the contents of the public folder into the /var/www/html folder and change index.php to point back to the rest of the laravel installation in /var/www/blog

Also, if you have full control over the server, you could have your Laravel installation anywhere you like, e.g. /home/username/my-laravel-project and have a vhost point to Laravel's default public directory. You don't have to move the directories around and change the index file like that (unless you're on shared hosting and have no alternatives).

Nash left a reply on 404 Not Found In Views Subfolders • 3 weeks ago

Does it work with 192.168.1.2/index.php/tasks? If so, you may need to enable the mod_rewrite module for Apache or try this alternative .htaccess file: https://laravel.com/docs/5.6/installation#web-server-configuration

Nash left a reply on Website Link Shared On Email • 3 weeks ago

it need to open a new window and open a compose mail with website link in body

That is what my example does.

Nash left a reply on Website Link Shared On Email • 3 weeks ago

Not really sure what you are trying to do? Is this what you want?

<a href="mailto:[email protected]?subject=Hello&body=www.">
    <img src="/assets/custom/images/drdrop/home/mail.png" width="33" height="33">
</a> 

31st May, 2018

Nash left a reply on Failed To Add The RSA Host Key For IP Address [IP] To The List Of Known Hosts . Permission Denied (publickey). • 3 weeks ago

You should not use sudo when generating the keys. Try again without sudo and copy the contents of the public key (/home/forge/.ssh/id_rsa.pub) to your GitHub settings.

30th May, 2018

Nash left a reply on Failed To Add The RSA Host Key For IP Address [IP] To The List Of Known Hosts . Permission Denied (publickey). • 3 weeks ago

Can Forge access the server? If not, you may need to add Forge's public key (see Server details -> Meta) to your server. Forge's key need to be in both the /home/forge/.ssh/authorized_keys file and the /root/.ssh/authorized_keys file on your server. Your own public key needs to be added to the server as well, but you should be able to add that via Forge (once it has access).

If you can't SSH in, you can get in via the console in the DigitalOcean control panel: https://www.digitalocean.com/community/tutorials/how-to-use-the-digitalocean-console-to-access-your-droplet#logging-in-with-the-console

Nash left a reply on Failed To Add The RSA Host Key For IP Address [IP] To The List Of Known Hosts . Permission Denied (publickey). • 3 weeks ago

You also need to add the server's public key to GitHub. It can be found under Server details -> Meta.

28th May, 2018

Nash left a reply on Laravel Integration With CloudFront • 3 weeks ago

Like the error message suggests, you probably just need to specify a region in your .env file or filesystems config. You may also need to specify the url.

Your region should be visible in the AWS/S3 console and the available values are listed here: https://docs.aws.amazon.com/general/latest/gr/rande.html#cf_region

26th May, 2018

Nash left a reply on Dive In PHP OOP • 3 weeks ago

The SOLID principles and Design Patterns series would be a good next step.

Nash left a reply on Dive In PHP OOP • 3 weeks ago

Check out the Laravel from Scratch series and if you need to brush up on PHP and OOP basics, check out the PHP practitioner and Object-Oriented Bootcamp series first.

24th May, 2018

Nash left a reply on A Security Question • 4 weeks ago

Check out HTMLPurifier for Laravel: https://github.com/mewebstudio/Purifier

16th May, 2018

Nash left a reply on Emails Are Coming From The Wrong Domain -- Every Other Time • 1 month ago

Try pushing the emails to separate queues:

$message = (new OrderShipped($order))
                ->onConnection('sqs')
                ->onQueue('site-one-emails');

Mail::to($request->user())
    ->queue($message);

https://laravel.com/docs/5.6/mail#queueing-mail

14th May, 2018

Nash left a reply on Accessing JSON Object With Foreach • 1 month ago

The inner loop has an associative array. Take a look at the very first example by @Cronix and how he loops through the two arrays. That is the right answer.

Nash left a reply on Accessing JSON Object With Foreach • 1 month ago

Yes, like I showed in my first post lol

@Cronix Exactly. It's just really easy to miss that second parameter and from the looks of it, that might just be what's missing.

Nash left a reply on Accessing JSON Object With Foreach • 1 month ago

It looks like you have an array with objects. Set the second parameter of json_decode to true to convert the objects into associative arrays:

$arr = json_decode($json, true);

13th May, 2018

Nash left a reply on Where Would You Save Dozens Of Lists Of Arrays? • 1 month ago

Isn't there a way to save a file to {name}.json in the Storage Folder and load the file?

Sure, for example:

// Array to JSON
$content_json = json_encode(['some' => 'array', 'with' => 'values']);

// Save file
Storage::put('file.json', $content_json);

// Fetch file from storage and convert JSON to array*
$content_array = json_decode(Storage::get('file.json'), true);

// * of course, you don't necessarily have to convert it back into an array if you intend to use it with JS only

Where you want to store the files is up to you. If it's not sensitive data, it could even be the public folder / the public disk for easy JS access. The default disk (storage/app) is ignored by Git by default...just something to remember if you want the files in your version control. You can easily change the location or create another disk (e.g. storage/myfiles) in filesystems.php.

12th May, 2018

Nash left a reply on Where Would You Save Dozens Of Lists Of Arrays? • 1 month ago

This largely depends on what it's for, how often it needs to be changed and by whom, but you could store them in a config or language file as arrays or in a JSON column in your db (MySQL 5.7+ or PostgreSQL).

Nash left a reply on Sublime Text 3 Highlights. • 1 month ago

Are you using build 3170? Apparently, this is a known issue. Let's hope it gets solved quickly.

For now, disabling the CSS3 package (or possibly some other conflicting package) seems to help for some.

https://github.com/Medalink/laravel-blade/issues/168

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.