/**
* Bring our routes online.
* @return Closure
*/
public static function getRoutes(): Closure {
return function () {
This file contains 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
/** | |
* On your resource, you need to override the getEloquentQuery method. Here is the original: | |
**/ | |
public static function getEloquentQuery(): Builder { | |
$query = static::getModel()::query(); | |
if ($tenant = Filament::getTenant()) { | |
static::scopeEloquentQueryToTenant($query, $tenant); | |
} |
This file contains 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 | |
namespace App\Rules; | |
use Illuminate\Validation\Rules\Password as Rule; | |
/** | |
* A password rule for Laravel based on Stanford's best practices. | |
* https://uit.stanford.edu/service/accounts/passwords | |
* |
This file contains 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 | |
namespace App\Console\Commands; | |
use Illuminate\Console\Command; | |
use DB; | |
/** | |
* In no way is this complete, but should give you a good starting point. | |
**/ |
This file contains 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
/** | |
* This is a dead simple way to share your current user within all views in a traditional website. | |
* Make sure you are importing Illuminate\Support\Facades\View into your AppServiceProvider, | |
* then add this to the boot method. Once you do that, you can use the $user variable at | |
* any point in the view to get your currently authenticated view. | |
*/ | |
View::share('user', \Auth::user()); |
This file contains 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
$files = []; | |
foreach ([ | |
app_path('Models/*.php'), | |
app_path('*.php'), | |
] as $path) { | |
$folder = dirname($path); | |
if (!file_exists($folder) || !is_dir($folder)) { | |
continue; | |
} | |
$files = array_merge($files, glob($path)); |
This file contains 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
This is a very inefficient way to do it once the db is huge. But it works. For the example, the user id is 5. | |
$userId = 5; | |
\DB::statement('SET @row=0'); | |
$user = \App\Models\User::whereRaw('1=1') | |
->select([ | |
\DB::raw('@row:=@row+1 as row'), | |
\DB::raw('count(*) as c'), | |
'users.*' | |
]) |
This file contains 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 | |
namespace App\Traits; | |
use Illuminate\Support\Facades\Hash; | |
/** | |
* Trait HasPasswordAttribute | |
* @package App\Traits | |
*/ |
This file contains 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 | |
// Customize this. | |
namespace Crumbls\ExtendedData\Traits; | |
use Str; | |
use Illuminate\Support\Facades\Cache; | |
use Illuminate\Support\Facades\Schema; | |
use Illuminate\Support\Facades\DB; |
This file contains 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 | |
/** | |
* Author: Chase C. Miller | |
* Working Date: 2017-01-11 | |
* Custom cache key for WPEngine to bypass object caching problems that can happen when you install a secondary or multisite on WPEngine. | |
* It should be installed as a mu-plugin to catch early activation. | |
**/ | |
global $wp_object_cache; |
NewerOlder