Questions tagged insert

Explore the latest questions and answers asked by our top developers.

$request->ajax is false in insert

I would like to insert data into a database, but in controller is $request->ajax() false. Can anybody help me? I spent a whole day on Google, but nothing helped me. I am using laravel 8. I used ajax for filter books. It works fine. But here I don’t know where the error is. When I […]

By Peter Kulas
Published
Categorised as ajax, database, insert, laravel, request Tagged , , , ,

Laravel: How do I insert a multidimensional array in the controller

Table: this is the table being used from the SQL database (id is auto incremented) Array: then output below is from the console of the browser after adding in: dd($replies); The screenshot below shows the input of the ui, which is the same data registered in the array in the screenshot above Entities: The function […]

Laravel: Could not insert data but don’t catch any error

I try to run a cronjob to insert about 60000 rows into DB: DB::beginTransaction(); try { DB::table(‘pharmacies’)->delete(); foreach(array_chunk($data, 50) as $piece) { Pharmacy::insert($piece); } DB::commit(); Log::debug("Save successfully"); } catch(Exception $e) { DB::rollback(); Log::debug($e->getMessage()); } } The cronjob is working normally. I test for a few first times, it saves successfully. But then, It suddenly can’t […]

By Lam
Published
Categorised as exception, insert, laravel Tagged , ,

Why registerController is not inserting data to database in laravel

I am new to laravel. I want to insert users data to database using registerController in laravel. What I have tried is: register.blade.php @extends(‘adminlte::auth.auth-page’, [‘auth_type’ => ‘register’]) @php( $login_url = View::getSection(‘login_url’) ?? config(‘adminlte.login_url’, ‘login’) ) @php( $register_url = View::getSection(‘register_url’) ?? config(‘adminlte.register_url’, ‘register’) ) @if (config(‘adminlte.use_route_url’, false)) @php( $login_url = $login_url ? route($login_url) : ” ) […]

By Binsha
Published
Categorised as forms, insert, laravel, model-view-controller, php Tagged , , , ,

How to fetch value from text field using loop

I am new to laravel. I need to fetch the data from text fields which is generated using loop and its corresponding data What my twig file shows as: I need to fetch each count variable with its mileage data and insert it into the database. For example, if I enter text in count as […]

By Binsha
Published
Categorised as database, html-input, insert, laravel, mysql Tagged , , , ,

how to solve this error Argument 1 passed to IlluminateDatabaseGrammar::parameterize() must be of the type array, string given

I got this problem trying to get id by comparing user input with data in database. I am new in this and I tried some solution which not help at all. Below is my controller code: public function assign(Request $request) { $courselist = new Courselist; $coursecode = $request->input(‘coursecode’); $courseid = DB::select("select id from course where […]

By SHAHIR AZRIE
Published
Categorised as insert, laravel Tagged ,

Why when I add 4 data only 2 data comes in Laravel used add more

why when I add 4 data from 2 different warehouses, only 2 data comes in, and why is the result like this result1 result2 My Form Input in Index 0 <tr> <td><input type="text" name="item_code[]" class="form-control" placeholder="Kode Barang" required></td> <td><select class="form-control" name="itemcategory_id[]" required> <option>– Pilih Kategori –</option> @foreach($itemcategory as $row) <option value="{{ $row->id_item_category }}">{{ $row->itemcategory_name }}</option> […]

By Muhammad Fahmi
Published
Categorised as add, foreach, insert, laravel, mysql Tagged , , , ,

How prevent save same record many times

I have controller recieve 12 request from flutter app, the request is like this: data.map((e) async { Map list = { ‘username’: username, ‘club’: e.club, ‘price’: e.price, ‘surename’: e.surname, ‘id’: e.id, ‘league’: e.leagueName, }; try { var newurl = Uri.parse(url + ‘create_team’); var response = await http.post(newurl, body: jsonEncode(list), headers: { ‘Content-Type’: ‘application/json’, ‘Authorization’: ‘Bearer […]

By Sermed mayi
Published
Categorised as controller, insert, laravel, request Tagged , , ,

Laravel : insert random id on field have autoincrement id

I have generate random id function : class CreateRandomId{ public static function get_id($my_table) { $id = mt_rand(1000000, 9999999999); if(self::check_id($id,$my_table)){ get_id($my_table); } return $id; } public static function check_id($id,$my_table) { $table=DB::table($my_table)->where(‘id’,$id)->get(); if (count($table)==0){ return false; } return true; } } I used it and it is generate id correctly but when i want to save it […]

By Sermed mayi
Published
Categorised as auto-increment, insert, laravel Tagged , ,

Laravel insert sql: not null violation, looking for a column thats not existing

my laravel insert function in my controller is looking for a "created_by" column which I do not have. Model: class HmsBbrCategory extends Model { public $timestamps = false; protected $table = ‘hms_bbr_category’; protected $fillable = [ "id", "category_id", "category_name", "category_description" ]; } Controller: public function store(Request $request) { $validator = Validator::make($request->all(), [ ‘category_name’=>’required|max:191’, ‘category_description’=>’required|max:191’, ]); […]

By Button Press
Published
Categorised as function, insert, laravel, null, sql Tagged , , , ,
1 2 3

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq