Ok, je reçois Trying to get property of non-object
lorsque j'essaie d'obtenir les données de la base de données à l'aide de $settings = AdminSettings::first();
Voici le code du contrôleur
<?php
namespace App\Http\Controllers\AdminSettings;
use App\AdminSettings\AdminSettings;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class AdminSettingsController extends Controller
{
public function index()
{
$settings = AdminSettings::first();
return view('admins.settings.settings', compact('settings'));
}
}
Voici le code modal
<?php
namespace App\AdminSettings;
use Illuminate\Database\Eloquent\Model;
class AdminSettings extends Model
{
protected $table = 'site_settings';
protected $fillable = [
'site_title', 'site_url', 'email_from', 'email_to', 'timezone', 'date_format', 'time_format',
];
}
Ici, j'essaie de mettre le site_title into the input but I get Trying to get property of non-object
<div class="form-group">
<label for="site_title" class="form-label">Site Title</label>
<input type="text" class="form-control" name="site_title" id="site_title" value="{{ $settings->site_title }}"/>
</div>
lorsque j'essaie de dd($settings);
j'obtiens null