Why is blade file not show anything although code are correct in laravel 8 - laravel

I installed Laravel 8 and set up a blade file.
I moved resources folders css, js, and bootstrap files to public folder and loaded from blade file.
This is master.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link href="{{asset('css/app.css')}}" rel="stylesheet" type="text/css"/>
<script src="{{asset('js/app.js')}}"><script/>
<script src="{{asset('js/bootstrap.js')}}"><script/>
</head>
<body>
#yield('content')
</body>
</html>
This is welcome.blade.php
#extends('layouts.master')
#section('content')
<div id="loginbox" style="margin-top:50px;" class="mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2">
<div class="panel panel-info" >
<div class="panel-heading">
<div class="panel-title">Sign In</div>
<div style="float:right; font-size: 80%; position: relative; top:-10px">Forgot password?</div>
</div>
<div style="padding-top:30px" class="panel-body" >
<div style="display:none" id="login-alert" class="alert alert-danger col-sm-12"></div>
<form id="loginform" class="form-horizontal" role="form">
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input id="login-username" type="text" class="form-control" name="username" value="" placeholder="username or email">
</div>
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
<input id="login-password" type="password" class="form-control" name="password" placeholder="password">
</div>
<div class="input-group">
<div class="checkbox">
<label>
<input id="login-remember" type="checkbox" name="remember" value="1"> Remember me
</label>
</div>
</div>
<div style="margin-top:10px" class="form-group">
<!-- Button -->
<div class="col-sm-12 controls">
<a id="btn-login" href="#" class="btn btn-success">Login </a>
<a id="btn-fblogin" href="#" class="btn btn-primary">Login with Facebook</a>
</div>
</div>
<div class="form-group">
<div class="col-md-12 control">
<div style="border-top: 1px solid#888; padding-top:15px; font-size:85%" >
Don't have an account!
<a href="#" onClick="$('#loginbox').hide(); $('#signupbox').show()">
Sign Up Here
</a>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<div id="signupbox" style="display:none; margin-top:50px" class="mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2">
<div class="panel panel-info">
<div class="panel-heading">
<div class="panel-title">Sign Up</div>
<div style="float:right; font-size: 85%; position: relative; top:-10px"><a id="signinlink" href="#" onclick="$('#signupbox').hide(); $('#loginbox').show()">Sign In</a></div>
</div>
<div class="panel-body" >
<form id="signupform" class="form-horizontal" role="form">
<div id="signupalert" style="display:none" class="alert alert-danger">
<p>Error:</p>
<span></span>
</div>
<div class="form-group">
<label for="email" class="col-md-3 control-label">Email</label>
<div class="col-md-9">
<input type="text" class="form-control" name="email" placeholder="Email Address">
</div>
</div>
<div class="form-group">
<label for="firstname" class="col-md-3 control-label">First Name</label>
<div class="col-md-9">
<input type="text" class="form-control" name="firstname" placeholder="First Name">
</div>
</div>
<div class="form-group">
<label for="lastname" class="col-md-3 control-label">Last Name</label>
<div class="col-md-9">
<input type="text" class="form-control" name="lastname" placeholder="Last Name">
</div>
</div>
<div class="form-group">
<label for="password" class="col-md-3 control-label">Password</label>
<div class="col-md-9">
<input type="password" class="form-control" name="passwd" placeholder="Password">
</div>
</div>
<div class="form-group">
<label for="icode" class="col-md-3 control-label">Invitation Code</label>
<div class="col-md-9">
<input type="text" class="form-control" name="icode" placeholder="">
</div>
</div>
<div class="form-group">
<!-- Button -->
<div class="col-md-offset-3 col-md-9">
<button id="btn-signup" type="button" class="btn btn-info"><i class="icon-hand-right"></i> &nbsp Sign Up</button>
<span style="margin-left:8px;">or</span>
</div>
</div>
<div style="border-top: 1px solid #999; padding-top:20px" class="form-group">
<div class="col-md-offset-3 col-md-9">
<button id="btn-fbsignup" type="button" class="btn btn-primary"><i class="icon-facebook"></i>   Sign Up with Facebook</button>
</div>
</div>
</form>
</div>
</div>
</div>
#endsection
route is default
Route::get('/', function () {
return view('welcome');
});
Console is not showing any errors and view is not showing anything.
Although the blade files are coded correctly, it is not working
when I remove asset files from , it show view .
So what wrong in asset file
Can someone explain this to me?

Related

Spring Security Binding Result always false

so.. I have a registration page and there are a lot of validations in there but my binding result is always false. After a few tries I found the problem but I don't know the solution. When I pass a parameter in the /processRegistrationForm method it doesn't work but when I delete the #RequestParam it works. Why the passed parameter is influencing the binding result and how can I resolve this?
registration-form.html
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Register New User Form</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Reference Bootstrap files -->
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
.error {color:red}
</style>
</head>
<body>
<div>
<div id="loginbox" style="margin-top: 50px;"
class="mainbox col-md-3 col-md-offset-2 col-sm-6 col-sm-offset-2">
<div class="panel panel-primary">
<div class="panel-heading">
<div class="panel-title">Register New User</div>
</div>
<div style="padding-top: 30px" class="panel-body">
<!-- Registration Form -->
<form th:action="#{/processRegistrationForm(flag=${flag})}"
th:object="${crmUser}" method="POST"
class="form-horizontal">
<!-- Place for messages: error, alert etc ... -->
<div class="form-group">
<div class="col-xs-15">
<div>
<!-- Check for registration error -->
<div th:if="${registrationError}" class="alert alert-danger col-xs-offset-1 col-xs-10">
<span th:text="${registrationError}"></span>
</div>
</div>
</div>
</div>
<!-- User name -->
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input type="text" th:field="*{userName}" placeholder="username (*)" class="form-control" />
</div>
<div th:if="${#fields.hasErrors('userName')}"
style="margin-bottom: 25px" class="text-danger">
<ul>
<li th:each="err : ${#fields.errors('userName')}" th:text="'User name ' + ${err}" />
</ul>
</div>
<!-- Password -->
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
<input type="password" th:field="*{password}" placeholder="password (*)" class="form-control" th:errorclass="fieldError" />
</div>
<div th:if="${#fields.hasErrors('password')}"
style="margin-bottom: 25px" class="text-danger">
<ul>
<li th:each="err : ${#fields.errors('password')}" th:text="'Password ' + ${err}" />
</ul>
</div>
<!-- Confirm Password -->
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
<input type="password" th:field="*{matchingPassword}" placeholder="confirm password (*)" class="form-control" th:errorclass="fieldError" />
</div>
<div th:if="${#fields.hasErrors('matchingPassword')}"
style="margin-bottom: 25px" class="text-danger">
<ul>
<li th:each="err : ${#fields.errors('matchingPassword')}" th:text="'Password ' + ${err}" />
</ul>
</div>
<!-- First name -->
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input type="text" th:field="*{firstName}" placeholder="first name (*)" class="form-control" th:errorclass="fieldError" />
</div>
<div th:if="${#fields.hasErrors('firstName')}"
style="margin-bottom: 25px" class="text-danger">
<ul>
<li th:each="err : ${#fields.errors('firstName')}" th:text="'First name ' + ${err}" />
</ul>
</div>
<!-- Last name -->
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input type="text" th:field="*{lastName}" placeholder="last name (*)" class="form-control" th:errorclass="fieldError" />
</div>
<div th:if="${#fields.hasErrors('lastName')}"
style="margin-bottom: 25px" class="text-danger">
<ul>
<li th:each="err : ${#fields.errors('lastName')}" th:text="'Last name ' + ${err}" />
</ul>
</div>
<!-- Email -->
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input type="text" th:field="*{email}" placeholder="email (*)" class="form-control" th:errorclass="fieldError" />
</div>
<div th:if="${#fields.hasErrors('email')}"
style="margin-bottom: 25px" class="text-danger">
<ul>
<li th:each="err : ${#fields.errors('email')}" th:text="'Email ' + ${err}" />
</ul>
</div>
<!-- Register Button -->
<div style="margin-top: 10px" class="form-group">
<div class="col-sm-6 controls">
<button type="submit" class="btn btn-primary">Register</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
controller:
#PostMapping("/processRegistrationForm")
public String processRegistrationForm(
#Valid #ModelAttribute("crmUser") CrmUser theCrmUser,#RequestParam(name="flag") Integer flag,
Model theModel,BindingResult theBindingResult) {
String userName = theCrmUser.getUserName();
// form validation
if (theBindingResult.hasErrors()){
return "registration-form";
}
// check the database if user already exists
User existing = userService.findByUserName(userName);
if (existing != null){
theModel.addAttribute("crmUser", new CrmUser());
theModel.addAttribute("registrationError", "User name already exists.");
return "registration-form";
}
// create user account
userService.save(theCrmUser);
if(flag==0)
return "redirect:/user";
else return "redirect:/list";
}
The problems are here:
/register-form:
<!-- Registration Form -->
<form th:action="#{/processRegistrationForm(flag=${flag})}"
th:object="${crmUser}" method="POST"
class="form-horizontal">
/processRegisterForm:
PostMapping("/processRegistrationForm")
public String processRegistrationForm(
#Valid #ModelAttribute("crmUser") CrmUser theCrmUser,#RequestParam(value = "flag",required = false) Integer flag,
BindingResult theBindingResult,
Model theModel) {...

Selection variable expressions fields are not working in Thymeleaf

I properly define everything in my back end file. When I try to use
the back end variables in Thymeleaf by using selection variable
expression it is not working. It show errors in every field:
cannot resolve field name
register.html
<!doctype html "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head th:replace="/fragments/head"></head>
<body>
<nav th:replace="/fragments/nav :: nav-front"></nav>
<div class="container-fluid mt-5">
<div class="row">
<div th:replace="/fragments/categories"></div>
<div class="col"></div>
<div class="col-6">
<h3 class="display-4">Register</h3>
<form method="post" th:object="${user}" th:action="#{/register}" >
<div th:if="${#fields.hasErrors('*')}" class="alert alert-danger">
There are errors
</div>
<div class="form-group">
<label for>Username:</label>
<input type="text" class="form-control" th:field="*{username}" placeholder="Username">
<span class="error" th:if="${#fields.hasErrors('username')}" th:errors="*{username}"></span>
</div>
<div class="form-group">
<label for>Password:</label>
<input type="password" class="form-control" th:field="*{password}">
<span class="error" th:if="${#fields.hasErrors('password')}" th:errors="*{password}"></span>
</div>
<div class="form-group">
<label for>Confirm Password:</label>
<input type="password" class="form-control" th:field="*{confirmPassword}">
<span class="error" th:if="${passwordMatchProblem}">Passwords do not match</span>
</div>
<div class="form-group">
<label for>E-mail:</label>
<input type="email" class="form-control" th:field="*{email}" placeholder="E-mail" required>
<span class="error" th:if="${#fields.hasErrors('email')}" th:errors="*{email}"></span>
</div>
<div class="form-group">
<label for>Phone number:</label>
<input type="text" class="form-control" th:field="*{phoneNumber}" placeholder="Phone number">
<span class="error" th:if="${#fields.hasErrors('phoneNumber')}" th:errors="*{phoneNumber}"></span>
</div>
<button class="btn btn-danger mb-5">Register</button>
</form>
</div>
<div class="col"></div>
</div>
</div>
<div th:replace="/fragments/footer"></div>
</body>
</html>
I get errors everywhere I use the selection expression field.
Are you adding "user" to your model in your controller?
You need to add it to your model so Thymeleaf can access it.
addAttribute method can be used like so: model.addAttribute("user", myUser);

Form POST request does not submit to controller but GET request works fine

I'm trying to submit a POST request to a controller but controller does not respond to my request and no error has been thrown as well, however GET request works fine.
I'm using
<button type="submit" class="btn btn-primary">Submit</button>
to send my request at the controller and this the controller that will handle my request>>
#GetMapping("/flexfieldkeysegment/{keyFlexFieldSegmentId}")
public String editCategoryForm(#PathVariable Integer keyFlexFieldSegmentId, Model model) {
String tenantName=getCurrentTenant().getUser().getTenantName();
FlexFieldKeySegment segment = keySegment.findFlexFieldKeySegmentById(tenantName, keyFlexFieldSegmentId);
model.addAttribute("keySegment",segment);
return viewPrefix+"edit_flexfield_key_segment";
}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
layout:decorate="~{layout}">
<body>
<div layout:fragment="content">
<br /> <br /> <br />
<div class="col-md-6 col-md-offset-3">
<h3 class="sub-title theme-font"></h3>
<div class="panel panel-primary theme-font">
<div class="panel-heading">
<h3 class="panel-title">Accounting Flexfield Key Segment</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<form th:action="#{/flexfieldkeysegment/{keyFlexFieldSegmentId}(keyFlexFieldSegmentId=${keySegment.keyFlexFieldSegmentId})}"
th:object="${keySegment}" method="post"
enctype="multipart/form-data">
<p th:if="${#fields.hasErrors('global')}" th:errors="*{global}"
th:class="text-red">Incorrect data</p>
<!-- text input -->
<div class="form-group"
th:classappend="${#fields.hasErrors('keyFlexFieldSegmentCode')}? 'has-error'">
<label>Flexfield Segment Code <span style="color: red;">*</span></label>
<input type="text" class="form-control"
name="keyFlexFieldSegmentCode"
th:field="*{keyFlexFieldSegmentCode}"
placeholder="Enter Flexfield Key Segment Code" />
<p th:if="${#fields.hasErrors('keyFlexFieldSegmentCode')}"
th:errors="*{keyFlexFieldSegmentCode}" th:class="text-red">Incorrect
data</p>
</div>
<div class="form-group"
th:classappend="${#fields.hasErrors('name')}? 'has-error'">
<label>Flexfield Key Segment Name<span
style="color: red;">*</span></label> <input type="text"
class="form-control" name="name" th:field="*{name}"
placeholder="Enter Flexfield Key Segment Name" />
<p th:if="${#fields.hasErrors('name')}" th:errors="*{name}"
th:class="text-red">Incorrect data</p>
</div>
<div class="form-group"
th:classappend="${#fields.hasErrors('description')}? 'has-error'">
<label>Description<span style="color: red;">*</span></label> <input
type="text" class="form-control" name="description"
th:field="*{description}"
placeholder="Enter Flexfield Key Segment Description" />
<p th:if="${#fields.hasErrors('description')}"
th:errors="*{description}" th:class="text-red">Incorrect
data</p>
</div>
<div class="form-group"
th:classappend="${#fields.hasErrors('separatorId')}? 'has-error'">
<label for="segment_separator">Segment Separator <span
style="color: red;">*</span></label> <select name="name"
id="separator" th:field="*{separatorId}"
th:data-validation-message="#{msg.flexfieldkeysegment.separator.mandatory}"
class="form-control dropdown">
<option th:value="''" th:text="'Select'"></option>
<option th:each="separator : ${segment_separator}"
th:text="${separator.separatorName}"
th:value="${separator.separatorId}"></option>
</select>
<p th:if="${#fields.hasErrors('separatorId')}"
th:errors="*{separatorId}" th:class="text-red">Incorrect
data</p>
</div>
<div class="form-group">
<div style="width: 30%; float: left; margin-right: 3%;">
<input type="checkbox" th:field="*{freezeFlexfieldDefinition}"
th:value="${freezeFlexfieldDefinition}" /> <label>Freeze
Flexfield Definition</label>
</div>
<div style="width: 30%; float: left; margin-right: 3%;">
<input type="checkbox" th:field="*{crossValidateSegment}"
th:value="${crossValidateSegment}" /> <label>Cross
Validate Segment</label>
</div>
<div style="width: 30%; float: left; margin-right: 3%;">
<input type="checkbox" th:field="*{freezeRollUpGroup}"
th:value="${freezeRollUpGroup}" /> <label>Freeze
Rollup Group</label>
</div>
<div style="width: 30%; float: left; margin-right: 3%;">
<input type="checkbox" th:field="*{allowDynamicInsert}"
th:value="${allowDynamicInsert}" /> <label>Allow
Dynamic Insert</label>
</div>
<div style="width: 30%; float: left; margin-right: 3%;">
<input type="checkbox" th:field="*{active}"
th:value="${active}" /> <label>Active</label>
</div>
</div>
</form>
</div>
</div>
<div class="box-footer">
<button type="button" class="btn btn-warning"
onclick="window.history.go(-1); return false;">
<span class="glyphicon glyphicon-arrow-left"></span> Back
</button>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Instead of #GetMapping, use #PostMapping. Also, annotate the 'Model' POJO with #RequestBody
#PostMapping("/flexfieldkeysegment/{keyFlexFieldSegmentId}")
public String editCategoryForm(#PathVariable Integer keyFlexFieldSegmentId, #RequestBody Model model) {
String tenantName=getCurrentTenant().getUser().getTenantName();
FlexFieldKeySegment segment = keySegment.findFlexFieldKeySegmentById(tenantName, keyFlexFieldSegmentId);
model.addAttribute("keySegment",segment);
return viewPrefix+"edit_flexfield_key_segment";
}

bootstrap-vue not passing array in checkbox

I'm using bootstrap-vue in my laravel project to pass data from the view to the database with checkboxes (b-form-checkbox), i want to select from the permissions passed from the database and assign it to a role, which means a role can have more than one permission, unfortunately the data is not persisting to the database as an array because if i select more than one in the checkbox it only shows the first one clicked. Please i need help as i have spent too much time on this issue. This is my code:
edit.blade.php
#extends('layouts.master')
#section('content')
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Admin
<small>Edit</small>
</h1>
<ol class="breadcrumb">
<li><i class="fa fa-dashboard"></i> Home</li>
<li>Role</li>
<li class="active">Edit</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
#include('layouts.partials.message')
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header with-border">
<h3 class="boxtitle">Edit Role</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<form action="{{ route('role.update', ['id' => $role->id]) }}" enctype="multipart/form-data" method="post" accept-charset="utf-8">
{{csrf_field()}}
<div class="row">
<div class="col-md-12">
<div class="form-group">
<input type="text" name="display_name" value="{{ old('display_name', $role->display_name) }}" class="form-control" placeholder="Name (Human Readable)" required>
<span class="help-block text-red">
#if($errors->has('display_name'))
{{ $errors->first('display_name')}}
#endif
</span>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<input type="text" name="name" value="{{ old('name', $role->name) }}" class="form-control" placeholder="Slug (can not be edited)" disabled>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<input type="text" name="description" value="{{ old('description', $role->description) }}" class="form-control" placeholder="Role Description">
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<h2>Permissions:</h2>
<b-form-group>
<b-form-checkbox-group v-model="permissionsSelected">
#foreach ($permissions as $permission)
<div class="form-group">
<b-form-checkbox id="permissions" name="permissions" value="{{ $permission->id }}">
<div class="form-group">
{{ $permission->display_name }} <em> ({{ $permission->description }})</em>
</div>
</b-form-checkbox>
</div>
#endforeach
</div>
</div>
<hr>
<div class="row">
<div class="col-md-1">
<div class="form-group">
<button class="btn btn-primary" type="submit" id="submit">
<i class="fa fa-check"></i> Submit
</button>
<input type="hidden" name="_token" value="{{ csrf_token() }}">
</div>
</div>
<div class="col-md-11">
<div class="form-group">
<div class="checkbox">
<label>
<input name="redirect" type="checkbox" checked> Redirect to role list after submission
</label>
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
</form>
</div>
</div>
</div>
</div>
</section>
#endsection
#section('vue')
<script>
var app = new Vue ({
el: '#app',
data: {
permissionsSelected: {!!$role->permissions->pluck('id')!!}
}
});
</script>
#endsection

Uploading files in Laravel 5

I'm trying to upload a file with Laravel but it does not work
I will send the field with the meta name view
<div class="panel-body">
<div class="tab-content">
<div class="tab-pane fade in active" id="tab1success">
<form method="post" name="type" action="songs">
{{ csrf_field() }}
<div class="form-group">
<div class="row">
<label class="col-md-3 control-label" for="Name">نام موزیک</label>
<div class="col-md-7">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-music">
</i>
</div>
<input id="Name" name="title" type="text"
placeholder="نام موزیک" class="form-control input-md">
</div>
</div>
</div>
<br>
<div class="row">
<label class="col-md-3 control-label" for="Name (Full name)">دسته
بندی</label>
<div class="col-md-7">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-list">
</i>
</div>
<select id="Name" name="category" type="دسته بندی"
placeholder="دسته بندی" class="form-control input-md">
<option>fun</option>
<option>love</option>
<option>birth</option>
<option>wedding</option>
</select>
</div>
</div>
</div>
<br>
<div class="row">
<label class="col-md-3 control-label" for="Name (Full name)">توضیحات</label>
<div class="col-md-7">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-file-text-o">
</i>
</div>
<textarea id="Name" name="text" placeholder="توضیحات"
class="form-control input-md"></textarea>
</div>
</div>
</div>
<br>
<div class="row">
<label class="col-md-3 control-label" for="Name (Full name)">انتخاب
فایل</label>
<div class="col-md-7">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-folder-o">
</i>
</div>
<input id="meta" name="meta" type="file" placeholder="انتخاب فایل"
class="form-control input-md">
</div>
</div>
</div>
<br>
<div class="row" style="text-align: center">
<div class="col-md-10 " style="text-align: center">
<button id="Name" name="submit" type="submit" placeholder="انتخاب فایل"
class="form-control input-md" style="text-align: center">اضافه
</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
Controller
public function create(Request $req, $type) {
$this->authorize('is_admin');
$req->file('meta')->store('app');
// $path = Storage::putFile('app', $req->file('meta'))
}
error
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Call to a member function store() on null
Here is an image of the error
Does anybody know what i should do about this?
Add enctype="multipart/form-data" to your <form> tag in your blade:
<form method="post" name="type" action="songs" enctype="multipart/form-data">
Based on your blade file you can see that the file meta being uploaded is not required, so in your controller, you need to check if the file was sent before calling the store method on it. Check this:
public function create(Request $req, $type) {
$this->authorize('is_admin');
$file = $req->file('meta') ? $req->file('meta')->store('app') : null;
}

Resources