Check this out: https://filamentadmin.com/
admin panel
Hello everyone, tell me or show me how to implement my own admin panel for a site on Laravel?
@benjamin1509 +1 for filament. Its really great
@benjamin1509 when creating an admin, it gives the following
php artisan make:filament-user
Name:
> admin
Email address:
> [email protected]
Password:
>
UnexpectedValueException
The stream or file "/home/sites/sumsi/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied
The exception occurred while attempting to log: The stream or file "/home/sites/sumsi/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied
The exception occurred while attempting to log: Add [name] to fillable property to allow mass assignment on [App\Models\User].
Context: {"exception":{}}
Context: {"exception":{}}
at vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:146
142▕ restore_error_handler();
143▕ if (!is_resource($stream)) {
144▕ $this->stream = null;
145▕
➜ 146▕ throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened in append mode: '.$this->errorMessage, $url) . Utils::getRecordMessageForException($record));
147▕ }
148▕ stream_set_chunk_size($stream, $this->streamChunkSize);
149▕ $this->stream = $stream;
150▕ }
+10 vendor frames
11 [internal]:0
Illuminate\Foundation\Bootstrap\HandleExceptions::Illuminate\Foundation\Bootstrap\{closure}()
my model User.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
use HasFactory;
}
@angerfist Try this if it will solve your problem.
chmod -R 777 /path/to/sumsi/storage/logs/laravel.log
or
chmod -R 777 /path/to/sumsi/storage/logs
or
sudo chmod -R 777 /path/to/sumsi/storage/logs/laravel.log
@benjamin1509 Add [name] to fillable property to allow mass assignment on [App\Models\User].
@benjamin1509 my model User.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
use HasFactory;
}
Add your other columns inside the $fillable.
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
protected $fillable = ['name', ....];
}
@benjamin1509 create model User.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
protected $fillable = ['name','slug'];
/*use HasFactory;*/
}
made a migration, then gave the command php artisan make:filament-user
after that gives
Illuminate\Database\QueryException
SQLSTATE[HY000]: General error: 1364 Field 'email' doesn't have a default value (SQL: insert into `users` (`name`, `updated_at`, `created_at`) values (ado, 2022-10-31 08:44:50, 2022-10-31 08:44:50))
@angerfist So add email to that array as well
@Sinnbeck no work
Filament\Commands\MakeUserCommand::createUser(): Return value must be of type Illuminate\Contracts\Auth\Authenticatable, App\Models\User returned
at vendor/filament/filament/src/Commands/MakeUserCommand.php:33
29▕ }
30▕
31▕ protected function createUser(): Authenticatable
32▕ {
➜ 33▕ return static::getUserModel()::create($this->getUserData());
34▕ }
35▕
36▕ protected function sendSuccessMessage(Authenticatable $user): void
37▕ {
+14 vendor frames
15 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
model User.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
protected $fillable = [
'name',
'slug',
'email',
'password'];
use HasFactory;
}
@angerfist It is extending the wrong model: https://github.com/laravel/laravel/blob/9.x/app/Models/User.php#L11
@Sinnbeck Thank you so much, what would I do without your help!
Please or to participate in this conversation.