My laravel project not validate all fileds of my register form
Url: http://themovingpixel.com/myfinancialgoals/register
My resources/views/auth/register.blade.php code is here
#extends('layouts.register')
#section('content')
<div class="stage_top_bg">Financial Advisors Register</div>
<div class="container">
<div class="financial_mid_box">
<form name="myform" action="{{ url('/register') }}" method="POST">
{{ csrf_field() }}
<div class="stage_box">
<div class="stage_one_box stage_active steps">Stage 1</div>
<div class="stage_two_box steps">Stage 2</div>
<div class="stage_three_box steps">Stage 3</div>
<div class="stage_four_box steps">Stage 4</div>
</div>
<div class="financial_form_box formone">
<div class="col-lg-6 col-md-6">
<div class="financial_fild_main_box"> <span class="name_text">Name</span>
<div class="name_fild">
<input name="name" class="name_main_fild" type="text" placeholder="Name">
</div>
#if ($errors->has('name'))
<span class="help-block"><strong>{{ $errors->first('name') }}</strong></span>
#endif
</div>
</div>
<div class="col-lg-6 col-md-6">
<div class="financial_fild_main_box"> <span class="name_text">Practice</span>
<div class="name_fild">
<input name="practice" class="name_main_fild" type="text" placeholder="Practice">
</div>
#if ($errors->has('practice'))
<span class="help-block"><strong>{{ $errors->first('practice') }}</strong></span>
#endif
</div>
</div>
<div class="col-lg-6 col-md-6">
<div class="financial_fild_main_box"> <span class="name_text">Phone</span>
<div class="name_fild">
<input name="phone_number" class="name_main_fild" type="tel" placeholder="Phone">
</div>
#if ($errors->has('phone_number'))
<span class="help-block"><strong>{{ $errors->first('phone_number') }}</strong></span>
#endif
</div>
</div>
<div class="col-lg-6 col-md-6">
<div class="financial_fild_main_box"> <span class="name_text">Email</span>
<div class="name_fild">
<input name="email" class="name_main_fild" type="text" placeholder="Email">
</div>
#if ($errors->has('email'))
<span class="help-block"><strong>{{ $errors->first('email') }}</strong></span>
#endif
</div>
</div>
<div class="col-lg-6 col-md-6">
<div class="financial_fild_main_box"> <span class="name_text">Password</span>
<div class="name_fild">
<input name="password" class="name_main_fild" type="password" placeholder="Password">
</div>
</div>
</div>
<div class="clearfix"></div>
<div class="procced_button">Proceed</div>
</div>
<div class="financial_form_box stepsone">
<div class="col-lg-6 col-md-6">
<div class="financial_fild_main_box"> <span class="name_text">Package</span>
<div class="name_fild">
<select name="packages" class="name_main_fild">
<option value="0">Select</option>
<option value="45">$45/month</option>
<option value="60">$60/month</option>
</select>
</div>
</div>
</div>
<div class="clearfix"></div>
<div class="procced_button btns">Proceed</div>
</div>
<div class="financial_form_box steptwo">
<div class="financial_fild_main_box"> <span class="name_text">Payment</span>
<div class="payament_box"> <!-- <a href="#">
<div class="payament_icon"><img src="{{ asset('assets/frontend/images/payaple_icon.jpg')}}" alt="icon"></div>
</a> <a href="#">
<div class="payament_icon"><img src="{{ asset('assets/frontend/images/ebay_icon.jpg')}}" alt="icon"></div>
</a> <a href="#">
<div class="payament_icon"><img src="{{ asset('assets/frontend/images/pay_icon_three.jpg')}}" alt="icon"></div>
</a> <a href="#">
<div class="payament_icon"><img src="{{ asset('assets/frontend/images/pay_icon_four.jpg')}}" alt="icon"></div>
</a> <a href="#">
<div class="payament_icon"><img src="{{ asset('assets/frontend/images/pay_icon_six.jpg')}}" alt="icon"></div>
</a> <a href="#">
<div class="payament_icon"><img src="{{ asset('assets/frontend/images/pay_icon_seven.jpg')}}" alt="icon"></div>
</a> <a href="#">
<div class="payament_icon"><img src="{{ asset('assets/frontend/images/pay_icon_eight.jpg')}}" alt="icon"></div>
</a> -->
<div class="name_fild">
<select name="payment_type" class="name_main_fild">
<option value="0">Select</option>
<option value="paypal">Paypal</option>
<option value="ebay">Ebay</option>
<option value="cirrus">Cirrus</option>
<option value="visa">Visa</option>
<option value="discover">Discover</option>
<option value="google">Google</option>
<option value="eway">Eway</option>
</select>
</div>
</div>
</div>
<div class="clearfix"></div>
<div class="procced_button"><button type="submit" class="process_btn">Proceed</button></div>
</div>
</form>
</div>
</div>
#endsection
And my app/Http/Controllers/Auth code is here
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use App\Userinfo;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class AuthController extends Controller
{
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
|
*/
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
/**
* Where to redirect users after login / registration.
*
* #var string
*/
protected $redirectTo = '/profile';
/**
* Create a new authentication controller instance.
*
* #return void
*/
public function __construct()
{
$this->middleware($this->guestMiddleware(), ['except' => 'logout']);
}
/**
* Get a validator for an incoming registration request.
*
* #param array $data
* #return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'practice' => 'required',
'password' => 'required|min:6|confirmed',
]);
}
/**
* Create a new user instance after a valid registration.
*
* #param array $data
* #return User
*/
protected function create(array $data)
{
//Validation
$this->validate($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'practice' => 'required|max:255',
'phone_number' => 'required|number',
'password' => 'required|min:6|confirmed',
]);
$insertedUserInfo = User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
// echo '<pre>'.print_r($userinfo,1).'</pre>';
// exit;
// $userinfo = new Userinfo;
// $userinfo->user_id = $insertedUserInfo->id;
// $userinfo->phone_number = $data['phone_number'];
// $userinfo->address = $data['address'];
// return $userinfo->save();
Userinfo::create([
'user_id' => $insertedUserInfo->id,
'phone_number' => $data['phone_number'],
'practice' => $data['practice'],
'dob' => $data['dob'],
'postcode' => $data['postcode'],
'gender' => $data['gender']
]);
return $insertedUserInfo;
}
}
Please help me to validate registration from this from data goes to 3tables users,userinfo tables.
First of all for this type of steps layout you should have some client side validation too.
For that you can use jquery validate.
Take a look at this
your validator will only validate fields inside array
$this->validate($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'practice' => 'required|max:255',
'phone_number' => 'required|number',
'password' => 'required|min:6|confirmed',
]);
So you have to pass field names to your validation array to validate that field.
Validate method expect 1st param as Request instance, but not array($data) as you made.
https://laravel.com/api/5.1/Illuminate/Foundation/Validation/ValidatesRequests.html#method_validate
Related
i'm working on a Laravel/Livewire project and my validation don't let my form to submit but errors are not shown in my blade .
i implemented my validation system same as Livewire documentation but it didn't work for me
even i tested some other ways like validator::make() but my bug didn't solved
my controller :
class Index extends Component
{
use WithPagination;
public $title, $en_title, $parent;
protected $rules = [
'title' => 'required',
'en_title' => 'required',
];
protected $paginationTheme = "bootstrap";
public function store()
{
$validate = $this->validate();
Category::create([
'title' => $this->title,
'en_title' => $this->en_title,
'parent_id' => $this->parent,
]);
$this->reset(['title', 'en_title', 'parent']);
session()->flash('add_category', 'دسته بندی با موفقیت اضافه شد');
}
}
my blade :
<form wire:submit.prevent="store" class="col-md-6">
<div>
<div class="form-group">
<label class="form-label">عنوان دسته بندی</label>
<input wire:model.defer="title" type="text" class="form-control" placeholder="نام دسته بندی">
#error('title') <div class="invalid-feedback">{{$message}}</div> #enderror
</div>
<div class="form-group">
<label class="form-label">title</label>
<input wire:model.defer="en_title" type="text" class="form-control" placeholder="عنوان انگلیسی دسته بندی">
#error('en_title') <div class="invalid-feedback">{{$message}}</div> #enderror
</div>
<div class="form-group">
<label class="form-label">دسته بندی والد</label>
<select wire:model.defer="parent" id="select-countries" class="form-control custom-select">
<option value="">بدون والد</option>
#foreach($categoriesCreate as $category)
<option value="{{$category->id}}">{{$category->title}}</option>
#if (count($category->childrenRecursive) > 0)
#include('layouts.partials', ['categories' => $category->childrenRecursive, 'level'=> 1, 'create' => 1])
#endif
#endforeach
</select>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-success mt-1 mb-1">افزودن</button>
<div wire:loading wire:target="store">
<div class="loader-wrapper d-flex justify-content-center align-items-center">
<div class="loader">
<div class="ball-pulse">
<div></div>
<div></div>
<div></div>
</div>
</div>
</div>
</div>
</div>
</form>
i don't know why but i removed invalid_feedback class from my #error() in my blade that related to bootstrap and my errors are shown
I am trying to redirect logged in users to the main dashboard view, that I've titled as "xwelcome.blade.php" temporarily.
I've attached my routes:
Route::get('xwelcome', [CustomAuthController::class, 'xwelcome']);
Route::get('login', [CustomAuthController::class, 'index'])->name('login');
Route::post('custom-login', [CustomAuthController::class, 'customLogin'])->name('login.custom');
Route::get('registration', [CustomAuthController::class, 'registration'])->name('register-user');
Route::post('custom-registration', [CustomAuthController::class, 'customRegistration'])->name('register.custom');
Route::get('logout', [CustomAuthController::class, 'logOut'])->name('logout');
This is my CustomAuthController:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Hash;
use Session;
use App\Models\User;
use Illuminate\Support\Facades\Auth;
class CustomAuthController extends Controller
{
public function index()
{
return view('auth.login');
}
public function customLogin(Request $request)
{
$request->validate([
'email' => 'required',
'password' => 'required',
]);
$credentials = $request->only('email', 'password');
if (Auth::attempt($credentials)) {
return redirect()->intended('xwelcome')
->withSuccess('Signed in');
}
return redirect("login")->withSuccess('Login details are not valid');
}
public function registration()
{
return view('auth.registration');
}
public function customRegistration(Request $request)
{
$request->validate([
'name' => 'required',
'email' => 'required|email|unique:users',
'password' => 'required|min:6',
]);
$data = $request->all();
$check = $this->create($data);
return redirect("xwelcome")->withSuccess('You have signed-in');
}
public function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password'])
]);
}
public function dashboard()
{
if(Auth::check()){
return view('xwelcome');
}
return redirect("login")->withSuccess('You are not allowed to access');
}
public function logOut() {
Session::flush();
Auth::logout();
return Redirect('login');
}
}
Login button:
<form role="form" method="post" action="{{ route('login.custom') }}">
#csrf
<div class="mt-4">
<div class="form-group">
<label class="form-control-label">Email address</label>
<div class="input-group input-group-merge">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fas fa-user"></i></span>
</div>
<input type="email" class="form-control" id="input-email" placeholder="name#example.com">
</div>
</div>
<div class="form-group mb-4">
<div class="d-flex align-items-center justify-content-between">
<div>
<label class="form-control-label">Password</label>
</div>
<div class="mb-2">
Lost password?
</div>
</div>
<div class="input-group input-group-merge">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fas fa-key"></i></span>
</div>
<input type="password" class="form-control" id="input-password" placeholder="Password">
<div class="input-group-append">
<span class="input-group-text">
<a href="#" data-toggle="password-text" data-target="#input-password">
<i class="fas fa-eye"></i>
</a>
</span>
</div>
</div>
</div>
<button type="submit" class="btn btn-sm btn-primary btn-icon rounded-pill">
<span class="btn-inner--icon"><i class="fas fa-long-arrow-alt-right"></i></span>
Sign In
</button></div>
</form>
After I fill in my test account details, and press the button, I see this in my address bar
https://example.com/login?_token=0GddRaD453thhRFL7KWgEQ5DnZ3q7B4rL5gaajuM
Any help would be appreciated. Cheers
I can't see the input fields in your form!.
Have you tried to display the errors after validating the form?.
I think that you are redirected back to :
https://example.com/login?_token=0GddRaD453thhRFL7KWgEQ5DnZ3q7B4rL5gaajuM
because you are missing the input:email and input:password, what your are seeing is only the csrf token that laravel generates.
i Think issue is on button . try this out
<form role="form" method="post" action="{{ route('login.custom') }}">
#csrf
<div class="mt-4">
<button type="submit" class="btn btn-sm btn-primary btn-icon rounded-pill">
<span class="btn-inner--icon"><i class="fas fa-long-arrow-alt-right"></i></span>
Sign In
</button></div>
</form>
you are missing name attribute in your input field. the code should look like
<form role="form" method="post" action="{{ route('login.custom') }}">
#csrf
<div class="mt-4">
<div class="form-group">
<label class="form-control-label">Email address</label>
<div class="input-group input-group-merge">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fas fa-user"></i></span>
</div>
<input name="email" type="email" class="form-control" id="input-email" placeholder="name#example.com">
</div>
</div>
<div class="form-group mb-4">
<div class="d-flex align-items-center justify-content-between">
<div>
<label class="form-control-label">Password</label>
</div>
<div class="mb-2">
Lost password?
</div>
</div>
<div class="input-group input-group-merge">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fas fa-key"></i></span>
</div>
<input name="password" type="password" class="form-control" id="input-password" placeholder="Password">
<div class="input-group-append">
<span class="input-group-text">
<a href="#" data-toggle="password-text" data-target="#input-password">
<i class="fas fa-eye"></i>
</a>
</span>
</div>
</div>
</div>
<button type="submit" class="btn btn-sm btn-primary btn-icon rounded-pill">
<span class="btn-inner--icon"><i class="fas fa-long-arrow-alt-right"></i></span>
Sign In
</button></div>
</form>
i am using MacsiDigital/laravel-zoom package but the problem is Call to a member function get() on null i dont know why and i made everything correct
i am using MacsiDigital/laravel-zoom package but the problem is Call to a member function get() on null i dont know why and i made everything correct
here is my code
this is my create blade
<form method="post" action="{{ route('online_classes.store') }}" autocomplete="off">
#csrf
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label for="Grade_id">{{ trans('Students_trans.Grade') }} : <span
class="text-danger">*</span></label>
<select class="custom-select mr-sm-2" name="grade">
<option selected disabled>{{ trans('Parent_trans.Choose') }}...</option>
#foreach ($Grades as $Grade)
<option value="{{ $Grade->id }}">{{ $Grade->name }}</option>
#endforeach
</select>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="Classroom_id">{{ trans('Students_trans.classrooms') }} : <span
class="text-danger">*</span></label>
<select class="custom-select mr-sm-2" name="class">
</select>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="section_id">{{ trans('Students_trans.section') }} : </label>
<select class="custom-select mr-sm-2" name="section_id">
</select>
</div>
</div>
</div><br>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label>عنوان الحصة : <span class="text-danger">*</span></label>
<input class="form-control" name="topic" type="text">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>تاريخ ووقت الحصة : <span class="text-danger">*</span></label>
<input class="form-control" type="datetime-local" name="start_time">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>مدة الحصة بالدقائق : <span class="text-danger">*</span></label>
<input class="form-control" name="duration" type="text">
</div>
</div>
</div>
<button class="btn btn-success btn-sm nextBtn btn-lg pull-right"
type="submit">{{ trans('Students_trans.submit') }}</button>
</form>
and this is my fillable model
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class online_class extends Model
{
protected $fillable = [
'grade_id',
'classroom_id',
'section_id',
'topic',
'start_at',
'duration',
'user_id',
'meeting_id',
'start_url',
'join_url',
'password',
];
public function user(){
return $this->belongsTo(User::class,'user_id');
}
}
and this is my store method in controller
public function store(Request $request)
{
$user = Zoom::user()->first();
$meeting = Zoom::meeting()->make([
'topic' => $request->topic,
'duration' => $request->duration,
'password' => $request->password,
'start_time' => $request->start_time,
'timezone' => 'Africa/Cairo',
]);
$meeting->settings()->make([
'join_before_host' => false,
'approval_type' => 1,
'registration_type' => 2,
'enforce_login' => false,
'waiting_room' => false,
]);
online_class::create([
'grade_id' => $request->grade,
'classroom_id' => $request->class,
'section_id' => $request->section_id,
'topic' => $request->topic,
'start_at' => $request->start_time,
'duration' => $meeting->duration,
'user_id' => Auth::user()->id,
'meeting_id' => $meeting->id,
'start_url' => $meeting->start_url,
'join_url' => $meeting->join_url,
'password' => $meeting->password,
]);
return $user->meetings()->save($meeting);
}
I got error Missing required parameter for [Route: battersecondinnings.update] [URI: battersecondinnings/{battersecondinning}] [Missing parameter: battersecondinning]. (View: C:\xampp\htdocs\ContentBaseApp - 1.0.2\resources\views\battersecondinnings\edit.blade.php)
This is my C:\xampp\htdocs\ContentBaseApp - 1.0.2\resources\views\battersecondinnings\edit.blade.php
#extends('layouts.app')
#section('content')
<div class="row">
<div class="col-lg-12 margin-tb">
<div class="pull-left">
<h2>Edit Batter</h2>
</div>
<div class="pull-right">
<a class="btn btn-primary" href="{{ route('battersecondinnings.index') }}"> Back</a>
</div>
</div>
</div>
#if ($errors->any())
<div class="alert alert-danger">
<strong>Whoops!</strong> There were some problems with your input.<br><br>
<ul>
#foreach ($errors->all() as $error)
<li>{{ $error }}</li>
#endforeach
</ul>
</div>
#endif
<form action="{{ route('battersecondinnings.update', $battersecondinnings->id) }}" method="POST" enctype="multipart/form-data">
#csrf
#method('PUT')
<div class="row">
<div class="form-group row">
<div class="col-md-6">
<strong>ব্যাটসম্যান:</strong>
<input type="text" name="name" value="{{ $battersecondinnings->name }}" class="form-control" placeholder="ব্যাটসম্যান">
</div>
</div>
<div class="form-group row">
<div class="col-md-6">
<strong>রান:</strong>
<input type="number" name="runs" value="{{ $battersecondinnings->runs }}" class="form-control" placeholder="রান">
</div>
</div>
<div class="form-group row">
<div class="col-md-6">
<strong>বল:</strong>
<input type="number" name="balls" value="{{ $battersecondinnings->balls }}" class="form-control" placeholder="বল">
</div>
</div>
<div class="form-group row">
<div class="col-md-6">
<strong>ছক্কা:</strong>
<input type="number" name="sixs" value="{{ $battersecondinnings->sixs }}" class="form-control" placeholder="ছক্কা">
</div>
</div>
<div class="form-group row">
<div class="col-md-6">
<strong>চার:</strong>
<input type="number" name="fours" value="{{ $battersecondinnings->fours }}" class="form-control" placeholder="চার">
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 text-center">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</form>
#endsection
This is my BattersecondiningsController.php
public function edit(Battersecondinnings $battersecondinnings)
{
return view('battersecondinnings.edit',compact('battersecondinnings'));
}
/**
* Update the specified resource in storage.
*
* #param \Illuminate\Http\Request $request
* #param \App\Models\Battersecondinnings $battersecondinnings
* #return \Illuminate\Http\Response
*/
public function update(Request $request, Battersecondinnings $battersecondinnings)
{
$request->validate([
'name' => 'required',
'runs' => 'required',
'balls' => 'required',
'sixs' => 'required',
'fours' => 'required',
]);
$battersecondinnings->update($request->all());
return redirect()->route('battersecondinnings.index')
->with('success','Batter second innings updated successfully');
}
But same things is working in products/edit.blade.php
<form action="{{ route('products.update', $product->id) }}" method="POST" enctype="multipart/form-data">
#csrf
#method('PUT')
This is ProductController.php
public function edit(Product $product)
{
return view('products.edit',compact('product'));
}
public function update(Request $request, Product $product)
{
$request->validate([
'name' => 'required',
'runs' => 'required',
'balls' => 'required',
'sixs' => 'required',
'fours' => 'required',
]);
$product->update($request->all());
return redirect()->route('products.index')
->with('success','Product updated successfully');
}
This is web.php
Route::resource('battersecondinnings', BattersecondinningsController::class);
In the Route 'battersecondinnings.update' what is missing is enctype="multipart/form-data". Add it and try again.
Please ckeck this answer in stackoverflow multipart/form-data meaning
I don't know why the page has to load twice to display comments.
Here is my route: Route::post('/addComment', 'CommentsController#addComment');
Here is my controller:
public function addComment(Request $request)
{
$this->validate($request, [
'name' => 'required',
'body' => 'required',
]);
$lesson_id = $request->lesson_id;
$comment = new Comment;
$comment->name = $request->input('name');
$comment->body = $request->input('body');
$comment->parrent_id = '0';
$comment->lesson_id = $request->lesson_id;
$comment->save();
return back();
}
Here is my view:
<div class="leave_review">
<h3 class="blog_heading_border"> コメント </h3>
{!! Form::open(['action' => ['CommentsController#addComment'], 'method' => 'POST', 'id' => 'postForm' ]) !!}
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
<input type="hidden" id ="lesson_id" name="lesson_id" value="{{$lesson->id}}" />
</div>
<div class="row">
<div class="col-sm-6">
#error('name')
<div class="alert alert-danger">{{ $message }}</div>
#enderror
{{Form::label('name','名前')}}
{{Form::text('name', '', ['class' => 'form-group', 'id' => 'name' ]) }}
</div>
<div class="col-sm-12">
#error('body')
<div class="alert alert-danger">{{ $message }}</div>
#enderror
{{Form::label('body','メッセージ')}}
{{Form::textarea('body', '', ['class' => 'form-group', 'id' => 'body']) }}
</div>
</div>
<div class="row">
<div class="col-md-12">
</div>
</div>
{{Form::submit('Submit', ['class' => 'send mt_btn_yellow pull-right', 'id' => 'submit'])}}
{!! Form::close() !!}
{{-- End add comment --}}
{{--Display comment--}}
<ol class="review-lists">
#foreach ($comment as $value)
<li class="comment">
<div class="activity_rounded">
<img src="/storage/icon/icon.jpg" alt="image"> </div>
<div class="comment-body">
<h4 class="text-left">{{$value->name}}
<small class="date-posted pull-right">{{ \Carbon\Carbon::parse($value->created_at)->diffForHumans() }}</small>
</h4>
<p>{{$value->body}} </p>
<button class="pull-left mt_btn_yellow" onclick="toggleReply('{{$value->id}}')">返事</button>
{{-- ENd Display comment--}}
#foreach ($comment as $value)
<li class="comment">
<div class="activity_rounded">
<img src="/storage/icon/icon.jpg" alt="image"> </div>
<div class="comment-body">
<h4 class="text-left">{{$value->name}}
<small class="date-posted pull-right">{{ \Carbon\Carbon::parse($value->created_at)->diffForHumans() }}</small>
</h4>
<p>{{$value->body}} </p>
<button class="pull-left mt_btn_yellow" onclick="toggleReply('{{$value->id}}')">返事</button>
{{-- ENd Display comment--}}
you don't have a #endforeach