hxnnxs
hxnnxs
FFilament
Created by hxnnxs on 2/27/2024 in #❓┊help
In some places, the language does not switch
I looked through the debugbar no, I didn't see anything special
10 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.
Tell me please
4 replies
FFilament
Created by Ajith Lal on 2/8/2024 in #❓┊help
How to write test for chart widgets or do we need to test chart widgets
Hi, add description for charts: https://filamentphp.com/docs/3.x/widgets/charts#adding-a-description , and here you can see some of the charts : https://filamentphp.com/docs/3.x/widgets/charts. P.S. I hope I understood you correctly 🙂
5 replies
FFilament
Created by hxnnxs on 2/6/2024 in #❓┊help
Add button in custom register page
<?php namespace App\Filament\Pages\Tenancy; use App\Models\Company; use Filament\Forms\Components\Select; use Filament\Forms\Components\TextInput; use Filament\Forms\Form; use Filament\Pages\Tenancy\RegisterTenant; use Illuminate\Database\Eloquent\Model; 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' ]) ]); } protected function handleRegistration(array $data): Company { $data['user_id'] = auth()->user()->id; $company = Company::create($data); $company->users()->attach(auth()->user()); return $company; } }
6 replies
FFilament
Created by hxnnxs on 2/5/2024 in #❓┊help
Filament\Forms\ComponentContainer::Filament\Forms\Concerns\{closure}(): Argument #1 ($component) mus
help me pls 😊
4 replies
FFilament
Created by hxnnxs on 2/1/2024 in #❓┊help
Error when transferring the project to prod: 403FORBIDDEN
Okay, thanks for taking the time to help me and achieve a bug fix, I appreciate it.
15 replies
FFilament
Created by hxnnxs on 2/1/2024 in #❓┊help
Error when transferring the project to prod: 403FORBIDDEN
Yes, you're right. I missed the moment. But now I have fixed everything, and I am faced with the error that after registration I still have a 403 error, but now I receive an email with verification. But when you click on the verification button, the user is not verified in the DB
15 replies
FFilament
Created by hxnnxs on 2/1/2024 in #❓┊help
Error when transferring the project to prod: 403FORBIDDEN
I inserted it into the provider ->email Verification(), but it doesn't work
15 replies
FFilament
Created by hxnnxs on 2/1/2024 in #❓┊help
Error when transferring the project to prod: 403FORBIDDEN
After registration, I get to the page with the creation of the company: http://localhost:8000/dashboard/new , but I get an error . User.php:
<?php

namespace App\Models;

use ...
class User extends Authenticatable implements HasTenants, FilamentUser
{
use HasApiTokens, HasFactory, Notifiable, TwoFactorAuthenticatable;
public function canAccessPanel(Panel $panel): bool
{
return str_ends_with($this->email, '@fintrack.space') && $this->hasVerifiedEmail();
}
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
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 ...
class User extends Authenticatable implements HasTenants, FilamentUser
{
use HasApiTokens, HasFactory, Notifiable, TwoFactorAuthenticatable;
public function canAccessPanel(Panel $panel): bool
{
return str_ends_with($this->email, '@fintrack.space') && $this->hasVerifiedEmail();
}
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
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 2/1/2024 in #❓┊help
Error when transferring the project to prod: 403FORBIDDEN
I fixed the error when logging in, but now I'm facing error 403 FORBIDDEN during registration
15 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
Yes, I'm not negative, I honestly don't know how my translator translates, but I understand that people here are trying to help newcomers like me. And the Api-service plugin : https://filamentphp.com/plugins/rupadana-api-service
7 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
Friend, I understand this perfectly well and I understand what I could do with normal Laravel application development, but I use a plugin where it should be automated, I fixed this error, but after this error the plugin cannot find the company id for no reason, although all the connections are present
7 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
help pls))))
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
Yes, indeed. I was a little stupid.😅
5 replies
FFilament
Created by hxnnxs on 1/18/2024 in #❓┊help
auto selecting company_id
Code:
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('company_id')
->reactive()
->options(\App\Models\Company::where('id', session()->get('company_id'))->pluck('name', 'id'))
->default(session()->get('company_id'))
->disabled(),
Forms\Components\TextInput::make('inn')
->required()
->numeric(),
Forms\Components\TextInput::make('kpp')
->required()
->numeric(),
Forms\Components\TextInput::make('ogrn')
->required()
->numeric(),
]);
}
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('company_id')
->reactive()
->options(\App\Models\Company::where('id', session()->get('company_id'))->pluck('name', 'id'))
->default(session()->get('company_id'))
->disabled(),
Forms\Components\TextInput::make('inn')
->required()
->numeric(),
Forms\Components\TextInput::make('kpp')
->required()
->numeric(),
Forms\Components\TextInput::make('ogrn')
->required()
->numeric(),
]);
}
10 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
I'm shocked! I just don't have the words to be honest. The fact is that everything worked fine before migrate:refresh, but after that this error appeared and I tried to fix it for more than 3 hours. Thank you so much for helping such complete beginners in filament like me, you are a pro!❤️
11 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
Maybe this will help somehow:
SQLSTATE[HY000]: General error: 1364 Field 'user_id' doesn't have a default value
INSERT INTO
`companies` (
`name`,
`short_name`,
`type`,
`updated_at`,
`created_at`
)
VALUES
(
asdasd,
asdasd,
Simplified,
2024 -01 -17 19: 41: 09,
2024 -01 -17 19: 41: 09
)
SQLSTATE[HY000]: General error: 1364 Field 'user_id' doesn't have a default value
INSERT INTO
`companies` (
`name`,
`short_name`,
`type`,
`updated_at`,
`created_at`
)
VALUES
(
asdasd,
asdasd,
Simplified,
2024 -01 -17 19: 41: 09,
2024 -01 -17 19: 41: 09
)
Also, because of what I did according to the guide, it is worth specifying the migration of the companies table :
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('companies', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('short_name');
$table->string('type');
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->timestamps();
$table->softDeletes();
});
Schema::create('company_user', function (Blueprint $table) {
$table->id();
$table->foreignId('company_id')->constrained();
$table->foreignId('user_id')->constrained();
$table->timestamps();

});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('company_user');
Schema::dropIfExists('companies');
}
};
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('companies', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('short_name');
$table->string('type');
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->timestamps();
$table->softDeletes();
});
Schema::create('company_user', function (Blueprint $table) {
$table->id();
$table->foreignId('company_id')->constrained();
$table->foreignId('user_id')->constrained();
$table->timestamps();

});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('company_user');
Schema::dropIfExists('companies');
}
};
11 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
I also attach the Company model with the members function :
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;

class Company extends Model
{
protected $fillable = [
'user_id',
'name',
'short_name',
'type',
];
public function members(): BelongsToMany
{
return $this->belongsToMany(User::class);
}
use HasFactory, SoftDeletes;
}
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;

class Company extends Model
{
protected $fillable = [
'user_id',
'name',
'short_name',
'type',
];
public function members(): BelongsToMany
{
return $this->belongsToMany(User::class);
}
use HasFactory, SoftDeletes;
}
11 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
Logs :
[previous exception] [object] (PDOException(code: HY000): SQLSTATE[HY000]: General error: 1364 Field 'user_id' doesn't have a default value at C:\\Users\\crash\\OneDrive\\Рабочий стол\\FinTrack\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Connection.php:580)
[stacktrace]
[previous exception] [object] (PDOException(code: HY000): SQLSTATE[HY000]: General error: 1364 Field 'user_id' doesn't have a default value at C:\\Users\\crash\\OneDrive\\Рабочий стол\\FinTrack\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Connection.php:580)
[stacktrace]
When I create a company, the user_id is not filled in, although everything is written correctly in RegisterCompany:
<?php
namespace App\Filament\Pages\Tenancy;

use App\Models\Company;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Pages\Tenancy\RegisterTenant;
use Illuminate\Database\Eloquent\Model;

class RegisterCompany extends RegisterTenant
{
public static function getLabel(): string
{
return 'Create company';
}
public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name'),
TextInput::make('short_name'),
Select::make('type')
->options([
'General' => 'General',
'Simplified' => 'Simplified',
'Patent' => 'Patent'
])
]);
}

protected function handleRegistration(array $data): Company
{

$company = Company::create($data);

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

return $company;
}
}
<?php
namespace App\Filament\Pages\Tenancy;

use App\Models\Company;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Pages\Tenancy\RegisterTenant;
use Illuminate\Database\Eloquent\Model;

class RegisterCompany extends RegisterTenant
{
public static function getLabel(): string
{
return 'Create company';
}
public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name'),
TextInput::make('short_name'),
Select::make('type')
->options([
'General' => 'General',
'Simplified' => 'Simplified',
'Patent' => 'Patent'
])
]);
}

protected function handleRegistration(array $data): Company
{

$company = Company::create($data);

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

return $company;
}
}
11 replies