小编cod*_*nja的帖子

如何在 laragon 中设置自定义虚拟主机名

我有一个名为“my-new-project”的项目(这只是一个示例)。使用 laragon 自动虚拟主机名功能,我可以通过http://my-new-project.test/浏览该项目

是否可以使用其他名称而不是该项目名称来浏览该项目,例如... http://project.test/

另外,位于 C:\larragon\etc\apache2\sites-enabled 内的 .conf 文件中的ServerNameServerAlias是什么?

apache laragon

6
推荐指数
1
解决办法
3万
查看次数

如何在laravel中使用多个whereHas

我将 where 与多个 whereHas() 一起使用,但没有得到预期的结果。

这是我的代码

public function getCommunityScoreByUser($user,$category_id) {
      $question_ids = $user->answers->pluck('question_id')->unique();

      $specialities = $this->speciality
                    ->whereHas('questions', function($qry) use($question_ids){
                        $qry->whereIn('questions.id', $question_ids);
                       })
                    ->orwhereHas('caseStudies', function($qry) use($user) {
                        $qry->where('user_id', $user->id);
                       })
                    ->where('is_active', 'Y')
                    ->where('category_id',$category_id)
                    ->withCount('answers')
                    ->withCount(['answers as bestAnswerCount' => function ($query) {
                                $query->where('question_answer.is_accepted','Y');
                                }])
                    ->with(['answers' => function ($query) {
                          $query->withCount(['votes' => function ($query) {
                                $query->where('count','1');
                             }]);
                      }])
                    ->get();
      foreach ($specialities as $speciality => $key) {
        $votes_count = 0;
        foreach ($key->answers as $key1 => $value) {
          $votes_count += $value->votes_count;
        }
        $key->votesCount = $votes_count; …
Run Code Online (Sandbox Code Playgroud)

laravel eloquent

1
推荐指数
1
解决办法
835
查看次数

在laravel formRequests 中获取输入值

这是我的FormRequest

<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use URL;
class CaseStudyUpdateRequest 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()
    {
      $id = $this->request->get('cspid');
      dump($this);
      dump($id);
      $prev_url = URL::previous();
      $url_arr = explode('/', $prev_url);
      $data = $this->request->all();
      dump($data);
        $rules = [
            // 'post_title' …
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-validation

1
推荐指数
1
解决办法
1933
查看次数

标签 统计

laravel ×2

apache ×1

eloquent ×1

laragon ×1

laravel-validation ×1

php ×1