laravel-5.4

SQLSTATE[HY000]: General error: 1364 Field 'branch_id' doesn't have a default value laravel 5.4

怎甘沉沦 提交于 2020-12-14 11:07:34
问题 Hello guys I need your help. I am a beginner in laravel 5.4. I am trying to add a field which is foreign key however it doesn't added and produce the error doesn't have a default value. Add view Then the error UsersController code: public function create() { $branches = Branch::pluck('name', 'id'); return view('users.create', ['branches' => Branch::all()]); } public function store(Request $request) { $this->validate($request, [ 'branch_id' => 'required', 'fname' => 'required', 'lname' =>

Where are namespaces declared in Laravel?

谁说我不能喝 提交于 2020-12-13 03:39:23
问题 I learned in php that to be able to use a namespace, you have to declare or include first. <?php namespace namespace_01; function f1() { echo 'this is function'; } use namespace_01 as test_namespace; test_namespace\f1(); ?> Almost all of laravel codes use namespaces. But where are they defined? Example, when I created a controller. <?php namespace App\Http\Controllers; use Illuminate\Http\Request; class controller1 extends Controller { // } where is Illuminate\Http\Request defined? 回答1: Open

Where are namespaces declared in Laravel?

为君一笑 提交于 2020-12-13 03:39:20
问题 I learned in php that to be able to use a namespace, you have to declare or include first. <?php namespace namespace_01; function f1() { echo 'this is function'; } use namespace_01 as test_namespace; test_namespace\f1(); ?> Almost all of laravel codes use namespaces. But where are they defined? Example, when I created a controller. <?php namespace App\Http\Controllers; use Illuminate\Http\Request; class controller1 extends Controller { // } where is Illuminate\Http\Request defined? 回答1: Open

convert null values into empty string in laravel 5.4

折月煮酒 提交于 2020-12-04 03:15:34
问题 I want to convert all null with empty string I have used array_walk_recursive but I haven't got what I want please help me to figure it out what I have done wrong here. protected function setData($key, $value) { $this->data[$key] = $value; array_walk_recursive($this->data, function (&$item, $key) { $item = null === $item ? '' : $item; }); return $this->data; } 回答1: well, that's just a lamp mistake in eloquent we always get result in eloquent object and here I'm passing eloquent object inside

convert null values into empty string in laravel 5.4

倖福魔咒の 提交于 2020-12-04 03:15:31
问题 I want to convert all null with empty string I have used array_walk_recursive but I haven't got what I want please help me to figure it out what I have done wrong here. protected function setData($key, $value) { $this->data[$key] = $value; array_walk_recursive($this->data, function (&$item, $key) { $item = null === $item ? '' : $item; }); return $this->data; } 回答1: well, that's just a lamp mistake in eloquent we always get result in eloquent object and here I'm passing eloquent object inside