- php assoc array to correct js array of objs
$data = [
'Users' => 'abc',
'posts' => 'blabla',
];
collect($data)->map(function ($v, $k) {
return [$data = [
'Users' => 'abc',
'posts' => 'blabla',
];
collect($data)->map(function ($v, $k) {
return [| <template> | |
| <div class="table-responsive"> | |
| <table class="table"> | |
| <thead> | |
| <tr> | |
| <th class="text-nowrap"> | |
| <a href="#" @click.prevent="sortChange('name')"> | |
| <span>Name</span> | |
| <i class="fa" :class="getClass('name', 'alpha')"></i> | |
| </a> |
| <?php | |
| // Usage: | |
| // Before | |
| @if ($errors->has('email')) | |
| <span>{{ $errors->first('email') }}</span> | |
| @endif | |
| // After: |
| desc: | |
| In addition, if the current time is less than 30 minutes from endhour, expired is also counted as expired. | |
| Array | |
| ( | |
| [0] => Array | |
| ( | |
| [date] => 2019-06-01 | |
| [week] => Saturday | |
| [subdate] => 06-01 |
| <?php | |
| namespace App\Providers; | |
| use Illuminate\Support\Facades\Blade; | |
| use Illuminate\Support\ServiceProvider; | |
| class AppServiceProvider extends ServiceProvider | |
| { | |
| /** |
| <?php | |
| // Register these inside a service provider: | |
| Blade::directive('route', function ($expression) { | |
| return "<?php echo route({$expression}) ?>"; | |
| }); | |
| Blade::directive('routeIs', function ($expression) { | |
| return "<?php if (request()->routeIs({$expression})) : ?>"; |
| select | |
| first_name, | |
| last_name | |
| from | |
| users | |
| left join | |
| companies on companies.id = users.company_id | |
| where ( | |
| companies.name like 'TERM%' or | |
| first_name like 'TERM%' or |
While refactoring some code into a reusable PHP Class I hit a brief roadblock where some code expected the [__FILE__ magic constant][file] file path. Since that value always refers to the specific file it's called from, it won't work from a separate Class file because the referenced path would be the parent instead of the child.
The full filepath of a child Class can be inferred from an inherited parent Class method by combining [get_class($this)][get_class] or [get_called_class()][get_called_class] with the [ReflectionClass::getFileName][getfilename] method like this:
// ParentClass.php
class ParentClass
{| <?php | |
| namespace App\Charts; | |
| use App\Support\Livewire\ChartComponentData; | |
| use ConsoleTVs\Charts\Classes\Chartjs\Chart; | |
| /** | |
| * Class WanSpeedTestsChart | |
| * |
| <?php | |
| $spaces = [ | |
| 'driver' => 's3', | |
| 'key' => env('DO_SPACES_KEY'), | |
| 'secret' => env('DO_SPACES_SECRET'), | |
| 'endpoint' => env('DO_SPACES_ENDPOINT'), | |
| 'region' => env('DO_SPACES_REGION'), | |
| 'bucket' => env('DO_SPACES_BUCKET') | |
| ]; |