Skip to content

Instantly share code, notes, and snippets.

View Mombuyish's full-sized avatar
Never stop progressing.

Yish Mombuyish

Never stop progressing.
View GitHub Profile
<?php
// Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables
public function bootstrap(Application $app)
{
if ($app->configurationIsCached()) { // if it cached, return empty
return;
}
$this->checkForSpecificEnvironmentFile($app);
<?php
// Illuminate\Foundation\Application
public function configurationIsCached()
{
return file_exists($this->getCachedConfigPath());
}
public function getCachedConfigPath()
<?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.
<?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
$app = new Illuminate\Foundation\Application(
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
);
...
// Here is the application starting.
$app = require_once __DIR__.'/../bootstrap/app.php';
...
# install
npm install -g vuepress
# create a markdown file
echo '# Hello VuePress' > README.md
# start writing
vuepress dev
# build to static files
<?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.
<?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
<?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()) {