Skip to content

Instantly share code, notes, and snippets.

View MACscr's full-sized avatar

Mark Chaney MACscr

View GitHub Profile
@MACscr
MACscr / carousel.blade.php
Last active August 31, 2023 12:15
Alpinejs Carousel
@MACscr
MACscr / FilamentTableTabs.php
Last active September 26, 2023 04:23
Standalone Filament Table Tabs
<?php
# App\Http\Livewire\Traits\FilamentTableTabs
namespace App\Http\Livewire\Traits;
trait FilamentTableTabs
{
public ?string $activeTab = null;
@MACscr
MACscr / CuratorImage.php
Created August 17, 2022 01:02
Laravel Component for Filament Curator Images. Accessed by GeneralSettings (spatie settings) or Curator Pubic Id
<?php
namespace App\View\Components;
use App\Settings\GeneralSettings;
use FilamentCurator\Models\Media;
use Illuminate\Contracts\View\View;
use Illuminate\Database\Eloquent\Model;
use Illuminate\View\Component;
@MACscr
MACscr / EditUser.php
Created January 20, 2022 11:01
Filament User Impersonation Button that works on User Edit/View Page
<?php
## bottom of EditUser.php. Could be on View as well.
protected function getActions(): array
{
return array_merge([
ImpersonateButton::make('impersonate'),
], parent::getActions());
}
@MACscr
MACscr / CreatePlan.php
Created January 16, 2022 01:30
Laravel Filament Admin Resource - Toggle Entire Table Column Hooks
<?php
namespace App\Filament\Resources\PlanResource\Pages;
use App\Filament\Resources\PlanResource;
use App\Models\Plan;
use Filament\Resources\Pages\CreateRecord;
class CreatePlan extends CreateRecord
{
@MACscr
MACscr / .gitignore
Created January 7, 2022 22:00 — forked from salcode/.gitignore
.gitignore file for a general web project - Bare Minimum Git
# -----------------------------------------------------------------
# .gitignore
# Bare Minimum Git
# https://salferrarello.com/starter-gitignore-file/
# ver 20210211
#
# From the root of your project run
# curl -O https://gist.githubusercontent.com/salcode/10017553/raw/.gitignore
# to download this file
#
@MACscr
MACscr / Transaction.php
Last active December 20, 2021 15:44
Observer to watch transactions associated with an invoice and mark paid/unpaid if transaction sums meet invoice total.
<?php
....
class Transaction extends Model
{
.....
public function monitor_transaction()
{
@MACscr
MACscr / BelongsToManyCheckboxList.php
Last active December 23, 2021 16:29
Checkbox Lists Field (WIP) for Filament Admin v2
<?php
namespace Filament\Forms\Components;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Support\Str;
class BelongsToManyCheckboxList extends MultiSelect
{
use Concerns\CanBeInline;
@MACscr
MACscr / gist:095ce5ef6f6f035f7d89a093269b7ffc
Last active May 26, 2021 17:15
Simple Role Based Laravel Gates
Just using a simple `role` field in the User table with a value like 'admin', then setting up the following gate in Providers/AuthServiceProvider.php
Gate::define('role', function ($user, ...$roles) {
if (in_array($user->role, $roles)) {
return true;
}
});
Then in my livewire component methods and such, I am using the following to check multiple roles:
@MACscr
MACscr / Tagify.php
Created May 24, 2021 22:03 — forked from localdisk/Tagify.php
Livewire Tagify Component
<?php
namespace App\Http\Livewire;
use App\Models\Tag;
use Illuminate\View\View;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\Container\BindingResolutionException;
use Livewire\Component;