laravel-5.2

Laravel - Upload File to Database

你说的曾经没有我的故事 提交于 2020-01-21 12:24:26
问题 These are what I have : Database table named lamanInformasi , which has field named isi . This is what I want : User can upload multiple document or image files, and the files will be stored to database. The file names will be saved to isi field, and the files itself will be saved to a folder named propic . User also can show the file they want on the website and download it. This is what I have done : I used bootstrap plugin to input file. I used this source. I just used files inside the js

How to set up Laravel 5.2 to connect to API

与世无争的帅哥 提交于 2020-01-17 06:08:22
问题 I have a backend C++ application that receives JSON requests using a standard TCP connection. This application manages all the business logic (user authentication, transaction processing, data requests and validation). How do I need to setup Laravel 5.2 to connect to this server for user authentication and also transaction processing? I do not need any database on the Laravel side as all the data will be accessed through the C++ application. As a bonus, I would also like to incorporate JWT

Counting Models related through manyToMany only if a pivot attribute null - Laravel

那年仲夏 提交于 2020-01-17 05:13:12
问题 I am elaborating code acquired here ManyToMany relation - how update attribute in pivot table what I want: I want to get a collection of Activities related to any weekly Routine . The pivot table's atribute done_at tells me when any activity (task) was completed. I can list and later ->count() activities related to parent model in manyToMany relation: public function activities() { return $this->belongsToMany('App\Models\Activity', 'activity_routine', 'routine_id', 'activity_id')->withPivot(

laravel + dropzone file not uploading

橙三吉。 提交于 2020-01-17 03:48:05
问题 Why is it the file i upload not reflecting on the request even though the file is uploaded successfully? HTML <div id="upload_excel" class="dropzone form-control"> <div class="fallback"> <input name="file" type="file" multiple /> </div> </div> JS var baseUrl = "{{ url('/') }}"; var token = "{{ Session::getToken() }}"; Dropzone.autoDiscover = false; var myDropzone = new Dropzone("#upload_excel", { paramName: "file", acceptedFiles: ".xls,.xlsx", maxFiles: 1, maxFilesize: 10, url: baseUrl + "

Laravel unit test with input with array name

痞子三分冷 提交于 2020-01-17 01:22:06
问题 Input I am trying to fill: <input type="text" id="order-number" name="order_numbers[]" class="form-control"> My unit test code: public function testSearch() { $this->actAsUser(); $this->visit('/orders') ->type('12001546', 'order_numbers[]'); } Error I am getting: 1) OrdersTest::testSearch InvalidArgumentException: Unreachable field "" 回答1: I had the same problem, couldn't find a better solution than // TestCase.php protected function storeArrayInput($values, $name) { $this->inputs[$name] =

Laravel , how to call a function from another controller

混江龙づ霸主 提交于 2020-01-16 19:41:37
问题 I have a controller with the "getUsers" function in a controller called "UserController" , and inside it I want to call a function of the "CarController" controller called "getCars", the two options I have are: a) Make the second call as "static" , then I can call it without instantiating the class b) Do not do that function of the static class and I call it in this way $ car_id = 100; $ userController = new UserController (); $ userController-> getCars ($ car_id); I do not know which is the

Relationships using Eloquent

心已入冬 提交于 2020-01-15 11:15:32
问题 I'm using Eloquent in Laravel 5 and am a bit confused in relations between tables. These are existing tables of a software and cannot be altered. I have the following tables that shows historical details of a student. All tables have model classes created. student ------- student_id (PK) first_name last_name class ----- class_id (PK) name section year //2012, 2013 etc student_id (FK) result ------ result_id (PK) class_id (FK) month // jan, feb etc status //pass or fail Below are the details

Relationships using Eloquent

霸气de小男生 提交于 2020-01-15 11:13:48
问题 I'm using Eloquent in Laravel 5 and am a bit confused in relations between tables. These are existing tables of a software and cannot be altered. I have the following tables that shows historical details of a student. All tables have model classes created. student ------- student_id (PK) first_name last_name class ----- class_id (PK) name section year //2012, 2013 etc student_id (FK) result ------ result_id (PK) class_id (FK) month // jan, feb etc status //pass or fail Below are the details

Remove index.php from URL, Laravel 5.2

故事扮演 提交于 2020-01-15 09:28:07
问题 I saw a lot of examples and tried a lot of solutions without success! I am trying to put my project to Ubuntu server with apache. everything its ok when I do : "/MYEXAMPLE/public/index.php/dashboard" But I want: "/MYEXAMPLE/public/dashboard" And there is the problem! "The requested URL /MYEXAMPLE/public/dashboard was not found on this server." My apache server has de mod_rewrite. My project folders are: - MYEXAMPLE --------- server.php --------- public ----------------.htaccess.php ----------

Method save does not exist when saving Laravel 5.2 model

烂漫一生 提交于 2020-01-15 04:26:30
问题 I have a simple form, one of the fields is 'resource'. I have an Item model which has many Resources. I'm trying to save both the Item and it's Resource from my form. Item.php: public function resource() { return $this->hasMany('App\Resource'); } public function addResource(Resource $resource) { return $this->resource->save($resource); } Resource.php: public function item() { return $this->belongsTo('App\Item'); } My save method in ItemsController: public function store(CreateItemRequest