2018年4月20日 星期五

Laravel Relationship - Foreign key delete

$user = User::find($id);
$user->tasks()->delete();
$user->delete();

from : https://laracasts.com/discuss/channels/eloquent/laravel-relationship-foreign-key-delete?page=1

2017年6月28日 星期三

Getting Valet - Not Found error

Error :
I'm trying to get Valet running on my Mac and I'm getting a Valet - Not Found error.

Warning: file_get_contents(/var/root/.valet/config.json): failed to open stream: Permission denied in /Users/Username/.composer/vendor/laravel/valet/server.php on line 23

Warning: Invalid argument supplied for foreach() in /Users/Username/.composer/vendor/laravel/valet/server.php on line 47
404 - Not Found
Solution:
if you have installed composer global package using sudo than file owner will be root, in server.php it is checking file owner and then setting VALET_HOME_PATH, you need to change owner ship of all global packages or laravel/valet only. better to change for all so next time composer update or install without sudo.
cd ~/.composer/

sudo chown -R $(whoami) vendor

now happy development with valet.

from : https://laracasts.com/discuss/channels/general-discussion/getting-valet-not-found-error?page=1

2017年6月27日 星期二

Laravel CLI fails to create new app due to Cannot use lexical variable $eventName as a parameter name

Turned out the issue is related to the guzzele version installed on the system.
After seeing similar issue reported around guzzle 5.3 on some other repositories/apps, confirmed my globally installed version by running composer global info guzzlehttp/guzzle and it was 5.3. Then updating my composer's global installation by running composer global updatesolved the problem, after seeing the update report as shown bellow, running the same laravel new app-namegenerates the application successfully.
Updating guzzlehttp/guzzle (5.3.0 => 6.2.3): Downloading (100%)

from : https://stackoverflow.com/questions/44100316/laravel-cli-fails-to-create-new-app-due-to-cannot-use-lexical-variable-eventnam

2015年7月6日 星期一

mac The box 'ubuntu/trusty64' could not be found or could not be accessed in the remote catalog.

$ sudo vi Vagrantfile
Just before the end of the file and the line that contains “end” add the following option:-
1
config.vm.box_download_insecure=true


reference : http://www.grantlittle.me/vagrant-working-with-a-proxy/

2015年5月7日 星期四

Homestead.yml reload


You can run homestead up --provision to force the reload of the Homestead.yaml file.

2015年5月2日 星期六

What’s the difference between composer dump-autoload, composer update and composer install?

The above text already explains the difference between those commands, but for fast readers:
  • composer install installs the vendor packages according to composer.lock (or creates composer.lock if not present),
  • composer update always regenerates composer.lock and installs the lastest versions of available packages based on composer.json
  • composer dump-autoload won’t download a thing. It just regenerates the list of all classes that need to be included in the project (autoload_classmap.php). Ideal for when you have a new class inside your project.
    • Ideally, you execute composer dump-autoload -o , for a faster load of your webpages. The only reason it is not default, is because it takes a bit longer to generate (but is only slightly noticable)

reference : http://www.developed.be/2014/08/29/composer-dump-autoload-laravel/

Laravel 5 IDE Helper Generator

reference : https://github.com/barryvdh/laravel-ide-helper