i tried to create new tenent but through the error of "SQLSTATE[42S22]: Column not found: 1054 Unknown column '' in 'where clause' (SQL: select count(*) as aggregate from Users where `` = [email protected]". but i created all required column in database users table.
create.blade.php
<div class="col-md-6">
<input id="name" type="text" class="form-control @error('name') is-invalid @enderror"
name="name" value="{{ old('name') }}" required autocomplete="name" autofocus>
@error('name')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<!-- email input field -->
<div class="form-group row">
<label for="email"
class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror"
name="email" value="{{ old('email') }}" required autocomplete="email" autofocus>
@error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<!-- domain Input Field -->
<div class="form-group row">
<label for="domain" class="col-md-4 col-form-label text-md-right">{{ __('Domain') }}</label>
<div class="col-md-6">
<input id="domain" type="text"
class="form-control @error('domain') is-invalid @enderror" name="domain"
value="{{ old('domain') }}" required autocomplete="name" autofocus>
@error('domain')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-8 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Save Tenant') }}
</button>
</div>
</div>
</form>
storeTenantRequest.php
use Illuminate\Foundation\Http\FormRequest;
class StoreTenantRequest extends FormRequest { /** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { return true; }
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required',
'email' => 'email|required|unique:Users,',
'domain' => 'required|unique:users',
];
}
}
TenentController
public function store(StoreTenantRequest $request) {
User::create($request->validated() + ['role_id'=> 2, 'password'=>'secreat']);
return redirect()->route('tenants.index');
}
web.php
Route::resource('tenants',TenantController::class);