hxnnxs
hxnnxs
FFilament
Created by hxnnxs on 9/7/2024 in #❓┊help
Please advise markdown editor
Hi all! I really need a markdown editor in my laravel project. please tell me good packages
4 replies
FFilament
Created by hxnnxs on 2/27/2024 in #❓┊help
In some places, the language does not switch
No description
10 replies
FFilament
Created by hxnnxs on 2/9/2024 in #❓┊help
Don't show workers count
Hey, guys! I am writing the widget code, the widget shows 0 instead of the actual number of employees. Code
Stat::make('Number of workers', Company::find(Filament::getTenant())->first()->companyStuffs->count())
->chart([0 , 0.5, 1, 1.5])
->color('success'),
Stat::make('Number of workers', Company::find(Filament::getTenant())->first()->companyStuffs->count())
->chart([0 , 0.5, 1, 1.5])
->color('success'),
2 replies
FFilament
Created by hxnnxs on 2/8/2024 in #❓┊help
I encountered a strange bug when creating a purchase or sale in the app.
No description
4 replies
FFilament
Created by hxnnxs on 2/6/2024 in #❓┊help
Add button in custom register page
Hello everyone how can I add a button on a custom registration page? I tried using : use Filament\Forms\Components\Actions\Action; but I get the error: App\Filament\Pages\Auth\Register::getBackToDashboardComponent(): Return value must be of type Filament\Forms\Components\Component, Filament\Forms\Components\Actions\Action returned
6 replies
FFilament
Created by hxnnxs on 2/5/2024 in #❓┊help
Filament\Forms\ComponentContainer::Filament\Forms\Concerns\{closure}(): Argument #1 ($component) mus
When I try to make the Return button to the authorization page, I get this error. Here is the code:

use App\Models\Company;
use Filament\Actions\Action;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Pages\Tenancy\RegisterTenant;

class RegisterCompany extends RegisterTenant
{
public static function getLabel(): string
{
return 'Create company';
}
public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name')
->required()
->placeholder('FinTrack LTD.')
->minLength(2)
->maxLength(20)
->prefixIcon('heroicon-o-home')
->unique(),
TextInput::make('short_name')
->required()
->prefixIcon('heroicon-o-home')
->placeholder('FT LTD.')
->minLength(2)
->maxLength(10)
->unique(),
Select::make('type')
->required()
->options([
'General' => 'General',
'Simplified' => 'Simplified',
'Patent' => 'Patent'
]),
Action::make('Auth')
->url(route('filament.dashboard.auth.login')),
]);
}

use App\Models\Company;
use Filament\Actions\Action;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Pages\Tenancy\RegisterTenant;

class RegisterCompany extends RegisterTenant
{
public static function getLabel(): string
{
return 'Create company';
}
public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name')
->required()
->placeholder('FinTrack LTD.')
->minLength(2)
->maxLength(20)
->prefixIcon('heroicon-o-home')
->unique(),
TextInput::make('short_name')
->required()
->prefixIcon('heroicon-o-home')
->placeholder('FT LTD.')
->minLength(2)
->maxLength(10)
->unique(),
Select::make('type')
->required()
->options([
'General' => 'General',
'Simplified' => 'Simplified',
'Patent' => 'Patent'
]),
Action::make('Auth')
->url(route('filament.dashboard.auth.login')),
]);
}
4 replies
FFilament
Created by hxnnxs on 2/1/2024 in #❓┊help
Error when transferring the project to prod: 403FORBIDDEN
Hello everyone when transferring a project from local to production in the filament, I get error 403 FORBIDDEN. Here's mine User.php :
<?php

namespace App\Models;

// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Filament\Models\Contracts\FilamentUser;
use Filament\Models\Contracts\HasTenants;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Jeffgreco13\FilamentBreezy\Traits\TwoFactorAuthenticatable;
use Laravel\Sanctum\HasApiTokens;
use \Filament\Panel;
use \Illuminate\Database\Eloquent\Model;
use \Illuminate\Support\Collection;

class User extends Authenticatable implements HasTenants
{
use HasApiTokens, HasFactory, Notifiable, TwoFactorAuthenticatable;

protected $fillable = [
'name',
'email',
'password',
];

/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];

/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];

public function companyContacts(): HasMany
{
return $this->hasMany(CompanyContact::class);
}
public function getTenants(Panel $panel): Collection
{
return $this->companies;
}

public function companies(): BelongsToMany
{
return $this->belongsToMany(Company::class);
}

public function canAccessTenant(Model $tenant): bool
{
return $this->companies->contains($tenant);
}


}
<?php

namespace App\Models;

// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Filament\Models\Contracts\FilamentUser;
use Filament\Models\Contracts\HasTenants;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Jeffgreco13\FilamentBreezy\Traits\TwoFactorAuthenticatable;
use Laravel\Sanctum\HasApiTokens;
use \Filament\Panel;
use \Illuminate\Database\Eloquent\Model;
use \Illuminate\Support\Collection;

class User extends Authenticatable implements HasTenants
{
use HasApiTokens, HasFactory, Notifiable, TwoFactorAuthenticatable;

protected $fillable = [
'name',
'email',
'password',
];

/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];

/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];

public function companyContacts(): HasMany
{
return $this->hasMany(CompanyContact::class);
}
public function getTenants(Panel $panel): Collection
{
return $this->companies;
}

public function companies(): BelongsToMany
{
return $this->belongsToMany(Company::class);
}

public function canAccessTenant(Model $tenant): bool
{
return $this->companies->contains($tenant);
}


}
15 replies
FFilament
Created by hxnnxs on 1/29/2024 in #❓┊help
Do I need to specify the creator of the plugin
Hello everyone, I am doing my mini public project on github using element php, in the README I indicated that I am working with these technologies. But I also use breezy and other filament libraries. Do I need to specify all libraries that have an MIT license, or is specifying only the filament sufficient?
4 replies
FFilament
Created by hxnnxs on 1/21/2024 in #❓┊help
SQLSTATE[HY000]: General error: 1364 Field 'tokenable_type' doesn't have a default value
Hello everyone I ran into a problem in the Api-service plugin again. This time the error is :
SQLSTATE[HY000]: General error: 1364 Field 'tokenable_type' doesn't have a default value
SQLSTATE[HY000]: General error: 1364 Field 'tokenable_type' doesn't have a default value
Although the documentation says that everything should be connected automatically, but I still have errors (I assume because of multi-tenancy) The plugin Model code and other necessary codes are provided below. Token.php (its plugin model) :
<?php

namespace Rupadana\ApiService\Models;

use App\Models\Company;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Laravel\Sanctum\PersonalAccessToken;

class Token extends PersonalAccessToken
{
use HasFactory;

public function company(): BelongsTo
{
return $this->belongsTo(Company::class);
}
protected $table = 'personal_access_tokens';
}
<?php

namespace Rupadana\ApiService\Models;

use App\Models\Company;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Laravel\Sanctum\PersonalAccessToken;

class Token extends PersonalAccessToken
{
use HasFactory;

public function company(): BelongsTo
{
return $this->belongsTo(Company::class);
}
protected $table = 'personal_access_tokens';
}
api-service.php:
<?php

// config for Rupadana/ApiService
return [
'navigation' => [
'group' => [
'token' => 'Company',
],
],
];
<?php

// config for Rupadana/ApiService
return [
'navigation' => [
'group' => [
'token' => 'Company',
],
],
];
Comapny.php:
<?php

namespace App\Models;
use ...
class Company extends Model
{
protected $fillable = [
'user_id',
'name',
'short_name',
'type',
];
public static array $allowedFields = [
'name'
];

// Which fields can be used to sort the results through the query string
public static array $allowedSorts = [
'name',
'created_at'
];

// Which fields can be used to filter the results through the query string
public static array $allowedFilters = [
'name'
];
public function token(): HasMany
{
return $this->hasMany(Token::class);
}
<?php

namespace App\Models;
use ...
class Company extends Model
{
protected $fillable = [
'user_id',
'name',
'short_name',
'type',
];
public static array $allowedFields = [
'name'
];

// Which fields can be used to sort the results through the query string
public static array $allowedSorts = [
'name',
'created_at'
];

// Which fields can be used to filter the results through the query string
public static array $allowedFilters = [
'name'
];
public function token(): HasMany
{
return $this->hasMany(Token::class);
}
7 replies
FFilament
Created by hxnnxs on 1/21/2024 in #❓┊help
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'personal_access_tokens.company_id' in 'where
No description
5 replies
FFilament
Created by hxnnxs on 1/18/2024 in #❓┊help
auto selecting company_id
No description
10 replies
FFilament
Created by hxnnxs on 1/17/2024 in #❓┊help
SQLSTATE[HY000]: General error: 1364 Field 'user_id' doesn't have a default value
Hello everyone I ran into a problem during the implementation of Multi-tenancy, I tried to do everything according to the documentation, but apparently I made a mistake somewhere. RegisterCompany.php :
<?php
// use ...
class RegisterCompany extends RegisterTenant
{
public static function getLabel(): string
{
return 'Create company';
}

/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function form(Form $form): Form
{
return $form
->schema([
Select::make('type')
->options([
'General' => 'General',
'Simplified' => 'Simplified',
'Patent' => 'Patent'
]),
TextInput::make('name'),
TextInput::make('short_name'),
]);
}

protected function handleRegistration(array $data): Company
{
$company = Company::create($data);

$company->members()->attach(auth()->user());

return $company;
}
}
<?php
// use ...
class RegisterCompany extends RegisterTenant
{
public static function getLabel(): string
{
return 'Create company';
}

/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function form(Form $form): Form
{
return $form
->schema([
Select::make('type')
->options([
'General' => 'General',
'Simplified' => 'Simplified',
'Patent' => 'Patent'
]),
TextInput::make('name'),
TextInput::make('short_name'),
]);
}

protected function handleRegistration(array $data): Company
{
$company = Company::create($data);

$company->members()->attach(auth()->user());

return $company;
}
}
Company model :
public function members():BelongsToMany
{
return $this->belongsToMany(User::class);
}

public function Requisite() : HasOne
{
return $this->hasOne(CompanyRequisite::class);
}
public function members():BelongsToMany
{
return $this->belongsToMany(User::class);
}

public function Requisite() : HasOne
{
return $this->hasOne(CompanyRequisite::class);
}

User model :
public function getTenants(Panel $panel): array|\Illuminate\Support\Collection
{
return $this->Companies;
}

public function Companies(): BelongsToMany
{
return $this->belongsToMany(Company::class);
}

public function canAccessTenant(Model $tenant): bool
{
return $this->companies->contains($tenant);
}
public function getTenants(Panel $panel): array|\Illuminate\Support\Collection
{
return $this->Companies;
}

public function Companies(): BelongsToMany
{
return $this->belongsToMany(Company::class);
}

public function canAccessTenant(Model $tenant): bool
{
return $this->companies->contains($tenant);
}
11 replies
FFilament
Created by hxnnxs on 1/16/2024 in #❓┊help
Сhoosing a company after registration
No description
6 replies
FFilament
Created by hxnnxs on 1/16/2024 in #❓┊help
Auto-refresh pages
No description
6 replies
FFilament
Created by hxnnxs on 1/14/2024 in #❓┊help
API-Driven Development
Hello everyone I recently started studying filament and would like to ask users if there is API-Driven Development support here, how it works and where you can read more about it
11 replies
FFilament
Created by hxnnxs on 1/12/2024 in #❓┊help
Error installing the filament
No description
17 replies