laravel

基于 Laravel + Vue 构建一个类似 Twitter 的 Web 应用

时光毁灭记忆、已成空白 提交于 2021-01-30 05:48:22
在这一篇示例教程中,我们将会构建一个类似 Twitter 的 Web 应用。我们将使用到 Laravel 和 Vue.js,并且在 Vue.js 中定义一些组件,此外,还会使用 Axios 来发送网络请求。当然,篇幅有限,我们不可能开发一个完整的 Twitter 应用,而是实现一个简化版:用户可以发送 Tweet 并在自己的时间线中看到,可以关注或取消关注其他用户,如果关注了其他用户,那么也可以看到关注用户发布的 Tweet。麻雀虽小,五脏俱全,希望大家可以通过这个简单的应用学会 Laravel 和 Vue.js 的基础用法。 安装配置 Laravel 首先,我们需要安装一个新的 Laravel 应用(也可以通过 Composer 安装,看个人喜好): laravel new laratwitter 进入该项目根目录,安装前端依赖: npm install 接下来,修改 .env 中数据库相关配置符合本地环境,然后通过如下命令生成用户认证脚手架代码: php artisan make :auth 运行如下命令生成相关数据表: php artisan migrate 接下来配置下 Web 服务器(使用 Valet 的话略过),我这里配置的域名是 laratwitter.test ,配置完成后重启下 Web 服务器,然后通过 http://laratwitter.test

How to unit test a web scraping service php unit

こ雲淡風輕ζ 提交于 2021-01-29 22:56:28
问题 I am currently developing a project in PHP + Laravel that needs to scrape data from two different websites. I am using the Goutte Scraping Library. I have 10 integration tests, where I use the Crawler object that Goutte's Client provide in order to get the specific data I want to scrape from each website. The tests work just fine (I even used infection library for mutant testing)... But the thing is that I thik there could be a way to unit test all the functions (therefore, the tests would

How to unit test a web scraping service php unit

廉价感情. 提交于 2021-01-29 22:35:01
问题 I am currently developing a project in PHP + Laravel that needs to scrape data from two different websites. I am using the Goutte Scraping Library. I have 10 integration tests, where I use the Crawler object that Goutte's Client provide in order to get the specific data I want to scrape from each website. The tests work just fine (I even used infection library for mutant testing)... But the thing is that I thik there could be a way to unit test all the functions (therefore, the tests would

Upload multiple files from Client to Server via API using HTTP guzzle in laravel 8

寵の児 提交于 2021-01-29 21:53:45
问题 I tested by postman to attach file with field fileupload[0](see screenshot below) that works fine, request is added and fileupload also uploaded to server. But I want to call that upload file api by my laravel HTTP Client I have tried below code $result = Http::attach( 'attachment', $request->fileupload )->asForm()->post('http://192.168.1.100/api/request/store', $form_param); my control in form upload: <input type="file" name="fileupload[]" multiple> But it seem like API server does not get

List of users with the highest sum of points

久未见 提交于 2021-01-29 20:59:30
问题 I would like to create a ranking ordered by the user who has the most "points" scored. My "points" table has these fields: user_id, type and quantity. In this example, user 1 has a total of 4 points, while user 2 has a total of 8. My dilemma after several unsuccessful tests, is to create a cycle that shows users with the highest sum of "quantity". How can I do? 回答1: you need to use selectRaw(sum(columan) as total) then group Point::selectRaw("SUM(quantity) as total_quantity,user_id")->groupBy

Unwanted validation rule being applied on password reset

China☆狼群 提交于 2021-01-29 20:46:09
问题 I'm trying to use the password reset ability of Laravel's authentication. After running make:auth command, inside my ResetPasswordController, I have overridden rules function of Illuminate\Foundation\Auth\ResetsPasswords trait as the following: protected function rules() { return [ 'token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed|min:4', ]; } So, I am trying to change the minimum length value to 4. But when I try to reset my password, a rule of minimum of

(php,laravel) how to delete multi images with its path in laravel

雨燕双飞 提交于 2021-01-29 20:15:06
问题 database id. project_id. type. images 1. 23. frontend 3344.png 2. 23. frontend. 3326.png 3. 23. er diagram 4290.png 4. 23 wireframe. 995.png 5. 23. wireframe. 8875.png view blade @foreach($project_data as $project) <td> <a title="delete" href="javascript:void(0);" class="confirmDelete" name="project_data" record="delete_project" recordid="{{$project['id']}}" style="color: red"><i class="fas fa-trash"></i></a> </td> @endforeach route Route::get('delete_project/{id}','ProjectDataController

Laravel 8 JetStream Bootstrap 4

老子叫甜甜 提交于 2021-01-29 19:57:39
问题 I am using the jetstream UI with Laravel 8 and I have checked an I am aware that the Laravel team has no plans to make a Bootstrap version of the UI but I'm only comfortable with bootstrap and can't use a CDN because I need to make changes to BS4. Is it possible to install BS4 and SASS on a Laravel project without affecting the Laravel JetStream UI. 回答1: By default Laravel Jetstream is powered by TailwindCSS. All defaults pages is made by this CSS framework but you can easily add Bootstrap to

Laravel: Create HasMany Relationship Based On Condition

妖精的绣舞 提交于 2021-01-29 19:45:20
问题 I need to display reproductions based on Gender Condition Reproduction Table: $table->bigIncrements('id'); $table->unsignedInteger('father_id'); $table->unsignedInteger('mother_id'); ... I need to retrieve reproductions according to the gender User.php public function reproductions(){ if($this->gender == 'm'){ return $this->hasMany(Reproduction::class, 'father_id'); }else{ return $this->hasMany(Reproduction::class, 'mother_id'); } } Reproduction Table: id father_id mother_id 1 1 2 2 1 3 3 1 4

SQLState[HY000] Connection refused Laravel with docker

爱⌒轻易说出口 提交于 2021-01-29 19:40:57
问题 I'm setting up an existing Laravel project on my local machine using Docker. I realize similar questions have been asked many different times and the common refrain is "change DB_HOST to 127.0.0.1 , however, my project already has that set. Whenever I try to run: docker-compose exec app php artisan migrate:install to set the DB up I get this error: In Connection.php line 664: SQLSTATE[HY000] [2002] Connection refused (SQL: create table `migrations` (`id` int unsigned not null auto_increment