tomc
tomc
Explore posts from servers
FFilament
Created by tomc on 4/9/2024 in #❓┊help
Upload Laravel Images to Azure Blobs Storage via Filament-Curator
How can I make it so that when I upload a file via curator picker it uploads to azure blobs storage while leaving behind a simple backup thumbnail, after a successful upload I want to return the url so I share for my frontend
2 replies
FFilament
Created by tomc on 4/8/2024 in #❓┊help
Curator Image Not Found (Production)
I am using curator but I am getting Not Found for image url in production, note that I am passing it through an API resource. However I can access the image fine in my localhost. below is my model; model :
<?php

namespace App\Models;

use Awcodes\Curator\Models\Media;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Category extends Model
{
use HasFactory;

/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
'slug',
'image_id',
'description',
'is_active'
];

/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'is_active' => 'boolean',
];

public function image(): BelongsTo
{
return $this->belongsTo(Media::class, 'image_id', 'id');
}

public function courses(): HasMany
{
return $this->hasMany(Course::class);
}

public function getImageUrlAttribute()
{
// Check if image relationship is loaded
if (!$this->relationLoaded('image')) {
return config('app.placeholder_image_url');
}
// Access image URL through the relationship
return $this->image->path;
}
<?php

namespace App\Models;

use Awcodes\Curator\Models\Media;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Category extends Model
{
use HasFactory;

/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
'slug',
'image_id',
'description',
'is_active'
];

/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'is_active' => 'boolean',
];

public function image(): BelongsTo
{
return $this->belongsTo(Media::class, 'image_id', 'id');
}

public function courses(): HasMany
{
return $this->hasMany(Course::class);
}

public function getImageUrlAttribute()
{
// Check if image relationship is loaded
if (!$this->relationLoaded('image')) {
return config('app.placeholder_image_url');
}
// Access image URL through the relationship
return $this->image->path;
}
and this is how I call it in my api resource;
'image' => $this->when(function () {
return $this->relationLoaded('image');
}, function () {
return optional($this->image)->url; // Access url only if image exists
}), // Include image URL only if image relationship is loaded
'image' => $this->when(function () {
return $this->relationLoaded('image');
}, function () {
return optional($this->image)->url; // Access url only if image exists
}), // Include image URL only if image relationship is loaded
kindly assist.
8 replies
FFilament
Created by tomc on 3/17/2024 in #❓┊help
I am trying to access a list of users who have a boolean "is_trainers" = true, kindly assist
Forms\Components\Select::make('course_trainer_id')
->relationship('trainers', 'name')
->preload()
->searchable()
->options(function (callable $get) {
return $get('users')
->where('is_trainer', true)
->pluck('id', 'name');
}),
Forms\Components\Select::make('course_trainer_id')
->relationship('trainers', 'name')
->preload()
->searchable()
->options(function (callable $get) {
return $get('users')
->where('is_trainer', true)
->pluck('id', 'name');
}),
4 replies
FFilament
Created by tomc on 3/12/2024 in #❓┊help
How I create images urls with "filament spatie media library" ?
How I create images urls with "filament spatie media library" ? if yes How do I do that, i am working with filament-api-service so I can make those image urls available for my frontend.
12 replies
FFilament
Created by tomc on 2/27/2024 in #❓┊help
Enquiry: running Breeze API beneath Filament v3
Hello, is it possible to have filamentphp v3 run as an admin panel on top of a laravel breeze project? are there any down sides to that approach considering that breeze uninstalls certain features from laravel upon activation? I want it such that filament would only work as admin panel and breeze would only send out end points for post/get for the frontend (Nuxt) to consume. can I use controllers without disturbing filaments livewire
2 replies
TCTwill CMS
Created by tomc on 6/18/2023 in #👊support
Customizing TwillCMS Admin
Is it possible to edit the twill admin interface? I would love to add a kanban board feature to a very basic CRM I am trying to put together for my client using this package "https://madewithvuejs.com/draggable-kanban-board".
3 replies
TCTwill CMS
Created by tomc on 6/18/2023 in #👊support
Capsule Navigation in admin
I have installed a capsule for homepage, However I am not able to make it appear on my admin via the navigation in my "AppServiceProvider.php" below is what I currently have;
<?php

namespace App\Providers;

use A17\Twill\View\Components\Navigation\Link;
use A17\Twill\Facades\TwillNavigation;
use A17\Twill\View\Components\Navigation\NavigationLink;

use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}

/**
* Bootstrap any application services.
*/
public function boot(): void
{
TwillNavigation::addLink(
NavigationLink::make()->forModule('articles')
);

TwillNavigation::addLink(
NavigationLink::make()->forModule('services')
);

//trying to get my capsule to appear at admin
$link = NavigationLink::make()->title('Homepage')->route('admin.homepages.landing')->icon('home');
TwillNavigation::addLink($link);
}
}
<?php

namespace App\Providers;

use A17\Twill\View\Components\Navigation\Link;
use A17\Twill\Facades\TwillNavigation;
use A17\Twill\View\Components\Navigation\NavigationLink;

use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}

/**
* Bootstrap any application services.
*/
public function boot(): void
{
TwillNavigation::addLink(
NavigationLink::make()->forModule('articles')
);

TwillNavigation::addLink(
NavigationLink::make()->forModule('services')
);

//trying to get my capsule to appear at admin
$link = NavigationLink::make()->title('Homepage')->route('admin.homepages.landing')->icon('home');
TwillNavigation::addLink($link);
}
}
Kindly assist.
2 replies