小编Leo*_*ent的帖子

系统中缺少所请求的PHP扩展名mbstring

我从作曲家那里得到的错误信息是:您的要求无法解析为可安装的一组包.

 Problem 1
    - Installation request for laravel/framework v5.4.28 -> satisfiable by laravel/framework[v5.4.28].
    - laravel/framework v5.4.28 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
  Problem 2
    - Installation request for phpunit/phpunit 5.7.21 -> satisfiable by phpunit/phpunit[5.7.21].
    - phpunit/phpunit 5.7.21 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
  Problem 3
    - laravel/framework v5.4.28 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/tinker …
Run Code Online (Sandbox Code Playgroud)

php mbstring laravel

7
推荐指数
2
解决办法
1万
查看次数

Laravel 5.5 request() - > all()没有获得所有输入

我正在使用Laravel 5.5.我正在尝试创建一个帖子,但是当我请求所有()数据从请求实例中转储时,我没有打印出所有字段.

这是我创建帖子的代码:

   /**

    * Persist new post.

    */
public function store()
{
    $this->validate(request(),[

        'title'=>'required' 
    ]);

        dd(request()->all());

        $path = CreatePhotoThumbnail(request()->file('photo'));

        auth()->user()->addPost(new Posts( [
        'title'=>request('title'),
        'body'=>request('body'),
        'photo'=> $path

    ]));
}
Run Code Online (Sandbox Code Playgroud)

我得到的print_R只是标题:

Array ( [_token] => MhOTEGkR1oDMc50q0FiJmI8JCAeuCRrFCfRHcKkq  [title] => test )
Run Code Online (Sandbox Code Playgroud)

编辑:

表格:

  <!-- Main (left side) -->

  <section style="margin-top:20px;">

    <div class="row">
        <div class="col-sm-12">

          <!-- post -->
          <article class="blog-post">


          <div class="post-entry">

          <h2>Create a Blog Post</h2>

          <p>Be as specific as u can:</p>


          <form name="" action="/posts/create" method="post" class="comment-form" enctype="multipart/form-data">
          {{csrf_field()}}
          <div style="display: …
Run Code Online (Sandbox Code Playgroud)

php laravel

7
推荐指数
1
解决办法
2万
查看次数

Laravel 5.4 Blade foreach循环

我正在建立一个场地管理系统,并且在目标网页上,我试图向访客显示所有可用的广告位。已预订的客房显示为不可用。我创建了两个变量,一个变量包含时间表中的信息,另一个变量包含预订表中的信息,并尝试使用Blade进行比较和显示。这就是我试图在刀片中实现它的方式:

@foreach($times as $time)   
 @foreach($bookings as $booking)
    <tr>
        @if($time->availble_times == $booking->booking_time)
            <td>{{$time->availble_times}}: not available</td>
        @else
            <tr><td>{{$time->availble_times}}</td>
        @endif
            </tr>
 @endforeach    
@endforeach 
Run Code Online (Sandbox Code Playgroud)

但这反而会一直显示预订表中尽可能多的记录。就像预订表中有两行一样,它显示两次时间,依此类推。以防万一,这是我的控制器功能:

 public function times(){
    $times = Times::all();
    $bookings = Bookings::all();
    return view('/test2')->with('times', $times)->with('bookings', $bookings);
}
Run Code Online (Sandbox Code Playgroud)

我最近开始做Laravel,无法弄清楚这个问题。我的问题是,我该如何解决n次显示问题并向用户显示哪些时间被预订以及哪些时间可用?

php laravel-5 laravel-blade laravel-5.4

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

Laravel没有将所有数据插入DB

我正在编写评论部分; 我从下面的表格中获取用户数据:

<div class="comment">
    <h2>Leave a comment</h2>
    <form method="post" action="/blog/{{$post->id}}/comments">
    {{csrf_field()}}

     <input type="text" name= "name" class="textbox" value="Name" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Name';}">
     <input type="text" name="email" class="textbox" value="Email" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Email';}">
     <textarea value="Message:" name="body" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Message';}">Message</textarea>

     <div class="smt1">
        <input type="submit" value="add a comment">
     </div>
   </form>
</div>
Run Code Online (Sandbox Code Playgroud)

我通过如下的CommentsController存储方法获取路径上的数据:

Route::post('/blog/{post}/comments','CommentsController@store');
Run Code Online (Sandbox Code Playgroud)

然后通过控制器的方法将它们存储在db上:`

    public function store(Post $post){


    Comment::create([
       'body'    => request('body'),
       'email' =>request('email'),
       'name' =>request('name'), …
Run Code Online (Sandbox Code Playgroud)

php mysql database blogs laravel

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

如何使用laravel队列邮件编写单元测试?

我已经完成了按队列发送邮件的代码,并且可以正常工作,并且我想为此编写一个测试(只是想测试应该正常发送而不会按队列失败的邮件,然后再发送给合适的人),但是如何?

Mail::to($user->email)->queue(new Welcome($user));
Run Code Online (Sandbox Code Playgroud)

email testing queue tdd laravel

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

如何迭代 guzzle 响应

我从 api 请求中得到了大量响应。任何想法如何迭代响应,以便我获得持续时间文本和值。这是我的回应。我试过 foreach 但不起作用:

array:1 [?
  "elements" => array:1 [?
    0 => array:3 [?
      "distance" => array:2 [?
        "text" => "293 mi"
        "value" => 470780
      ]
      "duration" => array:2 [?
        "text" => "4 hours 50 mins"
        "value" => 17411
      ]
      "status" => "OK"
    ]
  ]
Run Code Online (Sandbox Code Playgroud)

这就是我得到这个json的方式

 $items = json_decode((string) $response->getBody(), true)['rows'][0];
        dd($items);
Run Code Online (Sandbox Code Playgroud)

php laravel

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

返回数组以在laravel中查看

我有以下控制器,将此信息数组传递给我的视图

public function index ()
{
     public function index ()
     {
        $ information = [
        'nroclients' => '10',
        'nroservices' => '20',
        'nrousuers' => '30',
        'nroordensservices' => '40',
        ];
    
         return view ('dashboard.index', compact ('information'));
     }
}
Run Code Online (Sandbox Code Playgroud)

如何单独访问每个元素? index.blade.php

number of clients: {{information-> nroclients}} <br>
number of services: {{information-> nroservices}}
Run Code Online (Sandbox Code Playgroud)

这在我看来运行应该不起作用?

报告的错误是

(2/2)ErrorException试图获取非对象的属性(查看:C:\ wamp64\www\sistemtest\resources\views\panel\index.blade.php)

php laravel laravel-5

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