This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables | |
public function bootstrap(Application $app) | |
{ | |
if ($app->configurationIsCached()) { // if it cached, return empty | |
return; | |
} | |
$this->checkForSpecificEnvironmentFile($app); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Illuminate\Foundation\Application | |
public function configurationIsCached() | |
{ | |
return file_exists($this->getCachedConfigPath()); | |
} | |
public function getCachedConfigPath() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
protected function getFreshConfiguration() | |
{ | |
$app = require $this->laravel->bootstrapPath().'/app.php'; // require application kernel of laravel. | |
$app->useStoragePath($this->laravel->storagePath()); // storage path. | |
$app->make(ConsoleKernelContract::class)->bootstrap(); // bootstraping instanced of ConsoleKernelContract class. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Illuminate\Foundation\Console\ConfigCacheCommand | |
public function handle() | |
{ | |
$this->call('config:clear'); // clear your config cached if it exists. | |
$config = $this->getFreshConfiguration(); // get a new config |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$app = new Illuminate\Foundation\Application( | |
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__) | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
// Here is the application starting. | |
$app = require_once __DIR__.'/../bootstrap/app.php'; | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install | |
npm install -g vuepress | |
# create a markdown file | |
echo '# Hello VuePress' > README.md | |
# start writing | |
vuepress dev | |
# build to static files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// passing array. | |
public function store(Request $request) | |
{ | |
$data = $request->all(); | |
//array_set, array_add and others way. | |
array_set($data, 'status', 'draft'); | |
// accept array. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// User 1 exists, with account | |
$user1 = User::find(1); | |
$accountId = $user1->account->id; // 123 | |
// User 2 exists, without account | |
$user2 = User::find(2); | |
$accountId = $user2->account->id; // PHP Error: Trying to get property of non-object |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
abort_if(! Auth::user()->isAdmin(), 403); | |
abort_if(! Auth::user()->isAdmin(), 403, 'Sorry, you are not an admin'); | |
abort_if(Auth::user()->isCustomer(), 403); | |
// In "admin" specific controller | |
public function index() | |
{ | |
if (! Auth::user()->isAdmin()) { |
NewerOlder