sitesense

Experience

92,375

73 Best Reply Awards

  • Member Since 3 Years Ago
  • 79 Lessons Completed
  • 0 Favorites

11th October, 2015

sitesense left a reply on Schema Help • 2 years ago

Specifically the term you're looking for is 'nested sets'.

There are a couple right here:

https://github.com/etrepat/baum

https://github.com/lazychaser/laravel-nestedset

sitesense left a reply on Export Database Data From Local To Production • 2 years ago

Seeders are a good choice when it's a relatively small amount of data, otherwise just use mysqldump or a tool such as Navicat/Sequel Pro to export/import.

backup: # mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql

restore:# mysql -u root -p[root_password] [database_name] < dumpfilename.sql

sitesense left a reply on Composer Doesn't Work, OSX El Capitan. • 2 years ago

You're pretty stuffed unless you have a backup of the 'bin' folder. I'm not sure what else you have installed over a stock El Capitan but I guess you're missing a bunch of stuff now.

sitesense left a reply on Composer Doesn't Work, OSX El Capitan. • 2 years ago

@Kudos read my update above :)

sitesense left a reply on Composer Doesn't Work, OSX El Capitan. • 2 years ago

I used this on Yosemite and it worked just fine.

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

sitesense left a reply on Which OS Are Most Laravel Developers Using? • 2 years ago

@ionutbajescu I agree that most people replying to this thread are using OSX. In fact I just did a quick tally. Some replies were a bit vague so don't take these figures as perfectly accurate:

OSX = 24 | Windows = 13 | Linux = 9

Even so, I think there's more going on here. Without wanting to stereotype anybody, I think 'Apple' owners are more likely to respond to a thread like this. It's the 'in-crowd' thing.

You can't really argue with actual statistical figures though. Take a look at another source here: https://stackoverflow.com/research/developer-survey-2015#tech-os

Who knows though - perhaps Laravel/Laracasts does attract the kind of person who is also attracted to Apple products? That would be interesting.

9th October, 2015

sitesense left a reply on Which OS Are Most Laravel Developers Using? • 2 years ago

It's far from equally mixed. Take a look at the global market share which shows OSX at 7.79%, Windows (combined versions) at 77.12% and Linux trailing behind at just 1.62%.

Outside of the US, OSX (Mac) fairs even worse. In the UK the only people using Macs are 'artistic' types like graphic designers, with of course a small minority of other users.

By those numbers alone, most Laravel developers MUST be using Windows, but that doesn't mean that many wouldn't 'prefer' to use OSX, myself included.

sitesense left a reply on Undefined Class Auth, What To Do? • 2 years ago

Or you could also do this:

\Auth::attempt([...]);

sitesense left a reply on Generate Random Number Into Text Box • 2 years ago

No need for ajax at all, it could be as simple as this: https://jsfiddle.net/ofpab4e9/

sitesense left a reply on Local Environment Sites Timeout When Network Is Changed On OSX • 2 years ago

I've heard of this problem before although not had it myself.

Try changing the DNS settings on your macbook from automatic to Google's DNS (8.8.8.8) and see if that helps :)

sitesense left a reply on Generate Random Number Into Text Box • 2 years ago

Of course JS could be used, or PHP.

Show us what you have already, or make a start here: http://lmgtfy.com/?q=show+random+number+on+button+click

sitesense left a reply on Unable To Deploy • 2 years ago

You probably need to setup your SSH Keys in Bitbucket.

First you need the SSH key provided by Forge. I think you get this when you add the repository for your site but I can't remember.

Now go to your Bitbucket "account settings" and choose "SSH Keys" from the Security section (left hand side). Once there, click the "Add key" button to paste your key details. Once saved you should be good to go.

sitesense left a reply on Removing Direct Access To Index.php? • 2 years ago

That is no solution, you need to find out why you get a weird page because that's obviously not right.

What are the contents of this 'weird' page?

sitesense left a reply on Socialite - Connecting Social Accounts • 2 years ago

Also take a look at the link below. You 'can' get Email from Twitter but you need to get your application whitelisted - which isn't difficult.

https://dev.twitter.com/rest/reference/get/account/verify_credentials

sitesense left a reply on Revisions Table • 2 years ago

I shouldn't think a pivot table is required. Your second suggestion sounds just fine to me :)

sitesense left a reply on Styles Will Not Run On Some Specific Pages • 2 years ago

Are you using Laravel or Lumen?

Is you application within a sub-folder like http://localhost/your-app/ or do you use a proper domain mapped to your public folder?

sitesense left a reply on Homestead Aliases • 2 years ago

@steveabraham I've got to say that I've been using the standard Vagrant commands - vagrant up etc. since 5.1 and I think you're right about support for the Homestead commands being dropped.

sitesense left a reply on Styles Will Not Run On Some Specific Pages • 2 years ago

It's almost certainly a path issue. Try loading your styles and scripts like this:

<link rel="stylesheet" href="{{ URL::asset('css/app.css') }}">

<script type="text/javascript" src="{{ URL::asset('js/app.js') }}"></script>

sitesense left a reply on Homestead Aliases • 2 years ago

Make sure to place the ~/.composer/vendor/bin directory in your PATH so the homestead executable is found when you run the homestead command in your terminal.

sitesense left a reply on Trigger Code Execution When Session Expires • 2 years ago

Alternatively, just before the session ends you could popup a "Session will expire in 'n' seconds" reminder and if no action is taken - do your stuff.

28th September, 2015

sitesense left a reply on Sending Arrays Ajax To Vue Object • 2 years ago

Try this to encode your array:

public function nameOfFunction()
    {
        $instance = \App\Instance::next();
        $task = $instance->task;
        return json_encode(['name'=>$task->name, 'field'=>$instance->field]);
    }

sitesense left a reply on Times On Timesheet, Help With Some Javascript :) • 2 years ago

@lstables - I think your problem is below:

function nearestFullHour(seconds)
{
    // return Number(Math.floor(seconds/1800)/2).toFixed(2);
    return Number(seconds/1800/2).toFixed(2);
}

sitesense left a reply on Times On Timesheet, Help With Some Javascript :) • 2 years ago

Hi @lstables - I wonder if you might need to change your inputs to using a date/time format to allow for night working, for example starting at 22:00 and ending at 06:00 the following day?

With that in mind I've quickly done a JSFiddle that will work out the hours and minutes between 2 date/times. you can change the breaks variable to see how it effects the output.

https://jsfiddle.net/bj70cdyt/1/

I'm a bit pushed for time right now but if you need further help I'll try to back and run through your code after I finish this job :)

25th September, 2015

sitesense left a reply on Setting Up Fixed Variables Inside Controller To Be Used Across All Function In Class • 2 years ago

Hi @arsyan - a variable declared in a function is only accessible within that function - unless you were to pass it to another function like below:

public function write()
{
    $data = 'Hello';
    $this->say($data);
}

private function say($data)
{
    echo $data;
}

If you need a variable to be accessible to the whole class, then you must declare it at the top of the class and use $this->variable_name to access it.

Declaring a variable as private means that it can't be accessed from outside of the class.

Here's a link with some info that's quite easy to understand, regarding the use of 'public', 'private', and 'protected'. It's in Java but the same principal applies:

http://www.javacoffeebreak.com/faq/faq0002.html

sitesense left a reply on Setting Up Fixed Variables Inside Controller To Be Used Across All Function In Class • 2 years ago

Try it this way :)

<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use BlockIoPhp\BlockIoPhp\Lib\BlockIo;
use BlockIoPhp\BlockIoPhp\Lib\BlockKey;

class BlockioController extends Controller
{

    private $apiKey;
    private $pin;
    private $version;

    public function __construct()
    {
        //blockio init
        $this->apiKey = $_ENV['BLOCKIO_API_KEY'];
        $this->pin = $_ENV['BLOCKIO_PIN'];
        $this->version = 2; // API version    
    }

    public function checkAllBalance()
    {       
        ?><pre><?php
        $block_io = new BlockIo($this->apiKey, $this->pin, $this->version);
        $output = $block_io->get_my_addresses();        
        print_r($output);
    }

23rd September, 2015

sitesense left a reply on Importing 50k+ Rows To Database From CSV • 2 years ago

Personally I'd use the 'chunk' feature but dispatch the chunks to queues which will run in the background and not timeout.

http://laravel.com/docs/5.1/queues

It's too big a subject to offer a simple example, but hopefully it points you in the right direction and you can learn about it.

15th September, 2015

sitesense left a reply on L5 Maximum Function Nesting Level Of '100' Reached, Aborting! • 2 years ago

@CedNet you must have missed the part that describes how Laravel's dependency injection is a Symfony thing and the increase in function calls is relative to Symfony changes.

sitesense left a reply on Return A Response From A Method Called Within A Method. • 2 years ago

@chrislentz Don't take this the wrong way :)

I wouldn't waste time on micro-optimizations to code that doesn't bottleneck your application. If it works, move onto something else until it becomes a problem.

In my opinion, too much time and effort is wasted in 'doing it the right way', when there are many 'right ways' and it doesn't matter anyway.

Often the right way is the simplest and quickest way :)

sitesense left a reply on Server Security And Disabling Public Access To Data • 2 years ago

@mehany I dont see why being developed 'in-house' prevents usage of S3 but maybe that's a language/communication issue :)

No matter, still I would opt for a single location for assets (given enough capacity of course) and the link I sent you earlier will help whichever method you choose.

It's simply a case of checking that a user is allowed access to a file, and then serving that file to them if they do.

sitesense left a reply on Php Artisan Db:seed [InvalidArgumentException] Source Directory /tmp Does Not Exist Or Is Not A Directory. • 2 years ago

@buro-buro The third parameter (false) indicates whether to provide the 'fullPath' or not. :)

sitesense left a reply on Class 'App\Http\Controllers\Spatie\Browsershot\Browsershot' Not Found • 2 years ago

Actually, if you want to work with PhantomJS, I suggest you install Node ( https://nodejs.org ) and then run npm install phantomjs from the command line.

sitesense left a reply on Laracasts Forum Code • 2 years ago

I don't want it as a package but if the code is open source, i can take bits of what i need.

If you are competent enough to do the above, you should be able to take Flarum or some other system and add the "reputation system" yourself, no? :)

sitesense left a reply on Error With Lumen Under WAMP • 2 years ago

This SO answer might be what you are looking for: https://stackoverflow.com/questions/29728973/notfoundhttpexception-with-lumen

If you put your Lumen App inside a subfolder (relative to your web server), Lumen will fail because the getPathInfo method return wrong path. If you want to use real getPathInfo, you should add extra arguments in run() method.

sitesense left a reply on Server Security And Disabling Public Access To Data • 2 years ago

I don't know your client's budget or even the amount of data that needs to be stored, but if I were to streamline this system one of the first things I would consider is using Amazon S3 to store the assets for all applications. Keep it all in the same place and use the same code to access everything. This can be done securely with 'access keys': https://docs.aws.amazon.com/AmazonS3/latest/dev/MakingRequests.html#TypesofSecurityCredentials

The data also has redundancy built in and if it becomes corrupt - is automatically repaired.

Laravel has 'filesystem drivers' that work with S3 out of the box.

sitesense left a reply on Server Security And Disabling Public Access To Data • 2 years ago

This could be achieved by storing PDFs, images and other protected files in a folder below web root - and ensuring user's have authority to download the file before serving it to them.

I suggest you take a look at Laravel's 'filesystem' to see how you can securely store and access files either on your physical/virtual server or even in the cloud.

http://laravel.com/docs/5.1/filesystem

25th August, 2015

sitesense left a reply on I Have Problem To Redirect Ulr By Using Htaccess • 2 years ago

Take a look at this SO answer, it might be what you're looking for:

https://stackoverflow.com/questions/17023869/htaccess-301-redirect-with-encoded-hebrew-urls

3rd July, 2015

sitesense left a reply on Fortgot Vagrant Password • 2 years ago

I think the default password for Vagrant SSH is just that - vagrant

2nd July, 2015

sitesense left a reply on Complete Register And Login App With Socialite And Multiple Providers • 2 years ago

@TheHamsterOfGod @jekinney - actually Twitter has been able to provide email addresses since April 2015.

Just one caveat, you need to have your app whitelisted (which isn't difficult) - read this: https://dev.twitter.com/rest/reference/get/account/verify_credentials

Changes were made to The PHP League's 'oauth1-client' in May so any version of Socialite that has been updated since then will be able to retrieve a Twitter user's email address - provided you get your app whitelisted.

30th June, 2015

sitesense left a reply on Maximum Function Nesting Level Of '100' Reached, Aborting! Model Exception • 2 years ago

My guess in this case is that you're already borderline on recursive calls and a different method may take a few more calls.

If you choose to stick with 100 against the advice of XDebug and Symfony though, we could have this conversation forever.

Just increase it ffs :)

sitesense left a reply on Atom Editor • 2 years ago

I do like Atom, but no way does it open a project as quick as ST.

For fast edits, I still go to ST, anything else I use PHPStorm - BUT there's not much in it - I can imagine a time when Atom will be my first choice considering the pace of development.

27th June, 2015

sitesense left a reply on Maximum Function Nesting Level Of '100' Reached, Aborting! Model Exception • 2 years ago

@jekinney I'm not trying to belittle you at all. I don't care that you have a different opinion.

I'm simply trying to correct what I believe is misinformation and certainly a misunderstanding on your part.

Your comments above only strengthen the 'argument' (for want of a better word).

You state that you don't use XDebug - that right there is perhaps why your apps never had the problem - not that this error likely to show up in production anyway because XDebug shouldn't be enabled there.

This thread and the other linked thread is specifically about an XDebug error. Yes of course it only happens with XDebug installed - we know that.

You state:

Never ever set your nested level higher then a hundred. The error is because there is an error. If your code and query is correct you will never reach the default of 100.

But WHY? It's an XDebug setting!! The hint in in the name xdebug.max_nesting_level = 100

Why is it hacking to set this to 250 (Homestead does this already) or 256 (XDebug now recommends this)?

For all your 'experience' you're sadly failing to grasp something quite fundamental here.

So fine, don't agree - but why base this on the fact you have many applications THAT DON'T USE IT, - and never had that problem?

sitesense left a reply on Maximum Function Nesting Level Of '100' Reached, Aborting! Model Exception • 2 years ago

@jekinney Seriously :) are you actually reading this?

IMO looks like his opinion to get his package to work.

We are talking about Fabien Potencier here - the founder of Symfony - and the "package" that you refer to is the Dependency Injection component of Symfony - probably the most important part!

Not only that, but you seem oblivious to the fact that the developers of XDebug have increased the default to 256. It is NO LONGER 100.

Hmm, I don't know what more to say, I'll leave it there :)

sitesense left a reply on Maximum Function Nesting Level Of '100' Reached, Aborting! Model Exception • 2 years ago

@jekinney - when Fabien Potencier closes the 'bug' with the comment "Having a limit of 100 is way too low for a typical app" and XDegug raise the default themselves - why keep the limit at 100? I don't think you read the whole thread.

Reading the Symfony issue here, you'll see that it was changes to Symfony (2.64 to 2.65) that caused the problems that started to appear in L5. https://github.com/symfony/symfony/issues/13998

25th June, 2015

sitesense left a reply on Really Important - Homestead/Vagrant Problem • 2 years ago

@Gewora since you're using an OS that hardly anyone has even tried yet (beyond experimentation), you might be better asking your question to the Vagrant community - although I wouldn't even expect much response from there either.

Other observations though... jeez your an arrogant bar steward aren't you?

sitesense left a reply on Forge Email • 2 years ago

@mstnorris actually you can avoid it, it's just not 'necessary' for everyone though, although it would help if it was.

For those that do require real privacy, for example - journalists with 'secret' sources, lawyers defending 'human rights groups' (who are classed as terrorists by the NSA) - they would never send an email that required any amount of privacy via or to Gmail addresses anyway.

Like I said though, it's a huge subject and it requires nothing short of a revolution to reverse. Not really appropriate for this forum :)

sitesense left a reply on Maximum Function Nesting Level Of '100' Reached, Aborting! Model Exception • 2 years ago

@jekinney I think you're out of touch - read the thread that I linked to.

The XDebug creators themselves have already recognised that modern OOP php applications can easily surpass a nesting level of 100 and now they now default to 256. http://bugs.xdebug.org/bug_view_page.php?bug_id=00001100

Laravel Homestead currently has a default of 250.

Although this particular problem could certainly be caused by bad code, there is no reason whatsoever not to increase the nesting level to 250.

sitesense left a reply on Reload Foreach Loop • 2 years ago

Good luck :)

sitesense left a reply on Reload Foreach Loop • 2 years ago

Well you can return data from your Ajax call. Get it to return the 'unique id' and any other data that is necessary and insert it where necessary. :)

sitesense left a reply on Reload Foreach Loop • 2 years ago

@itzikbenh ...

if no one commented it will never render

Just make sure the container div exists whether there are comments or not and the comment WILL be rendered.

the second problem is that it messes the whole design

It will only mess up the design if you haven't matched the html correctly. What exactly is messed up?

Edit Your Profile
Update

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