Я создал laravel проект в xammp / localhost и помещаю sh в свой репозиторий github. Затем мне пришлось удалить свою локальную копию и переустановить xammp из-за ошибки mysql db. Поэтому я клонировал свой репозиторий вернуться к xammp / htdocs через командную строку. тогда я запустил
"composer установить"
"composer update"
"npm установить"
"npm run dev "
" php хранилище ремесленника: ссылка "
команды.
Но теперь кажется, что некоторые из пакетов поддержки загружаются неправильно .
Это ошибки, которые я получаю,
Подсветка \ База данных \ QueryException SQLSTATE [01000]: Предупреждение: 1265 Данные усечены для столбца «document_id» в строке 1 (SQL : вставить в значения leave_requests
(approved_by
, category
, created_at
, document_id
, end
, reason
, request_by
, start
, status
, type
) (? , полный день, 2020-03-17 10:32:29, 9a863c30-683a-11ea-aa56-115572db8558.jpg, 2020-03-19, sdfgh, 2, 2020-03-15, в ожидании, без оплаты))
и
Подсветка \ База данных \ QueryException SQLSTATE [23000]: Нарушение ограничения целостности: 1048 Столбец'mitted_by 'не может быть пустым (SQL: вставить в expense_claim
(amount
, approved_by
, bill_id
, created_at
, date
, reason
, request_by
, status
) значения (54,20,?, 6dc45780-683a-11ea-a 136-c3ad164f7663.jpg, 2020-03-17 10:31:14, 2020-03-15, sdfgh, 2, ожидается))
Они связаны с двумя формами, которые хранят значения в mysql дБ, и они прекрасно работали до переустановки. Вот код для этих форм,
<?php
namespace App\Http\Controllers;
use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Uuid;
class ExpenseClaimRequestController extends Controller
{
/**
* Show the application dashboard.
*
* @return \Illuminate\View\View
*/
public function index()
{
$id = auth()->id();
$expense_claim_requests = DB::table('expense_claim')->where('request_by', '=', $id)->get();
$to_approve = DB::table('expense_claim')->where('approved_by', '=', $id)->get();
return view('expense_claim.view', compact('expense_claim_requests','to_approve'));
}
public static function get_user_name($user_id)
{
$user_=DB::table('users')->select('name')->where([['id', '=', $user_id],])->first();
return $user_;
}
public static function reject(Request $request)
{
$claimid=$request->requestId;
DB::table('expense_claim')->where('claim_id', '=', $claimid)->update(['status' =>'rejected']);
return redirect()->to('/expenseClaim');
}
public static function approve(Request $request)
{
$claimid=$request->requestId;
DB::table('expense_claim')->where('claim_id', '=', $claimid)->update(['status' => 'approved']);
return redirect()->to('/expenseClaim');
}
/**
* Store new events.
*
* @return \Illuminate\View\View
* @param \App\Http\Request $request
*/
public function store(Request $request)
{
$id = auth()->id();
$doc = $request->file('bill');
$manager_supervisor = DB::table('users')->where('id', '=', $id)->first();
if($doc!=null){
$uuid = Uuid::generate()->string;
$bill_doc_name = $uuid.'.'.$doc->getClientOriginalExtension();
$folder = '/uploads/expense_claim/';
$filePath = $folder . $bill_doc_name;
$this->uploadOne($doc, $folder, 'public', $bill_doc_name);
}else{
$bill_doc_name =null;
}
if($request->claim_id_=="add"){
DB::table('expense_claim')->insert([
[
'bill_id'=>$bill_doc_name,
'reason' => $request->reason,
'date'=>$request->date_,
'amount'=>$request->amount,
'request_by'=>$id,
'approved_by'=>$manager_supervisor->supervisor_manager,
'status'=>"pending",
'created_at'=>now(),
],
]);
}else{
DB::table('expense_claim')->where('claim_id', '=', $request->claim_id_)->update(
array(
'bill_id'=>$bill_doc_name,
'reason' => $request->reason,
'date'=>$request->date_,
'amount'=>$request->amount,
'request_by'=>$id,
'approved_by'=>$manager_supervisor->supervisor_manager,
'status'=>"pending",
'updated_at'=>now(),
)
);
}
return redirect()->route('expenseClaim')->withStatus(__('Leave request successfully updated.'));
}
public static function destroy(Request $request)
{
$claimid=$request->requestId;
DB::table('expense_claim')->where('claim_id', '=', $claimid)->delete();
return redirect()->to('/expenseClaim');
}
public function index2(Request $request)
{
$claimid=$request->requestId;
if($claimid=="add"){
$claim_req =null;
}else{
$claim_req = DB::table('expense_claim')->where('claim_id', '=', $claimid)->first();
}
return view('expense_claim.add_edit',compact('claimid','claim_req'));
}
public function uploadOne(UploadedFile $uploadedFile, $folder = null, $disk = 'public', $filename = null)
{
$name = !is_null($filename) ? $filename : Str::random(25);
$path =storage_path('uploads/expense_claim/'.$filename.'');
if( Storage::exists($path)){
Storage::disk('public')->delete('uploads/expense_claim/'.$filename.'');
}
$file = $uploadedFile->storeAs($folder, $name, $disk);
return $file;
}
/**
* Store new events.
*
* @return \Illuminate\View\View
*
*/
public function download_file($file_name)
{
return response()->download(storage_path("app/public/uploads/expense_claim/{$file_name}"));
}
}
@extends('layouts.app')
@section('content')
@include('layouts.headers.cards')
<div class="container-fluid mt--7">
<div class="row">
<div class="col-xl-12 mb-5 mb-xl-0">
<div class="card bg-white shadow">
<div class="card-body">
<form id="addEventForm" method="post" enctype="multipart/form-data" action="{{ route('expenseClaim.store') }}" autocomplete="off">
@csrf
<div class="pl-lg-4">
<input type="text" name="claim_id_" id="input-claim_id" hidden>
<div class="form-group{{ $errors->has('bill') ? ' has-danger' : '' }}">
<label class="form-control-label" for="input-bill">{{ __('Receipt/Bill') }}</label>
<input type="file" name="bill" id="input-bill" class="form-control form-control-alternative{{ $errors->has('bill') ? ' is-invalid' : '' }}" >
</div>
<div class="form-group{{ $errors->has('reason') ? ' has-danger' : '' }}">
<label class="form-control-label" for="input-reason">{{ __('Reason') }}</label>
<input type="text" name="reason" id="input-reason" class="form-control form-control-alternative{{ $errors->has('reason') ? ' is-invalid' : '' }}" placeholder="{{ __('Reason') }}" required autofocus>
@if ($errors->has('reason'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('reason') }}</strong>
</span>
@endif
</div>
<div class="form-group{{ $errors->has('date_') ? ' has-danger' : '' }}">
<label class="form-control-label" for="input-date_">{{ __('Date') }}</label>
<input type="date" name="date_" id="input-date_" class="form-control form-control-alternative{{ $errors->has('date_') ? ' is-invalid' : '' }}" placeholder="{{ __('Date') }}" autofocus>
@if ($errors->has('date_'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('date_') }}</strong>
</span>
@endif
</div>
<div class="form-group{{ $errors->has('amount') ? ' has-danger' : '' }}">
<label class="form-control-label" for="input-amount">{{ __('Bill Amount') }}</label>
<input type="number" step=".01" min="0" name="amount" id="input-amount" class="form-control form-control-alternative{{ $errors->has('amount') ? ' is-invalid' : '' }}" placeholder="{{ __('Bill amount') }}" autofocus>
@if ($errors->has('amount'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('amount') }}</strong>
</span>
@endif
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary mt-4">{{ __('Save') }}</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
var claim_id = @json($claimid);
var val = @json('add');
var values=@json($claim_req);
$("#input-claim_id").val(claim_id);
});
</script>
@include('layouts.footers.auth')
</div>
@endsection
@push('js')
<script src="{{ asset('argon') }}/vendor/chart.js/dist/Chart.min.js"></script>
<script src="{{ asset('argon') }}/vendor/chart.js/dist/Chart.extension.js"></script>
@endpush
и вторая форма,
@extends('layouts.app')
@section('content')
@include('layouts.headers.cards')
<div class="container-fluid mt--7">
<div class="row">
<div class="col-xl-12 mb-5 mb-xl-0">
<div class="card bg-white shadow">
<div class="card-body">
<form id="addEventForm" method="post" enctype="multipart/form-data" action="{{ route('leave.store') }}" autocomplete="off">
@csrf
<div class="pl-lg-4">
<input type="text" name="leave_id_" id="input-leave_id" hidden>
<div class="form-group{{ $errors->has('leave_document') ? ' has-danger' : '' }}">
<label class="form-control-label" for="input-leave_document">{{ __('Document') }}</label>
<input type="file" name="leave_document" id="input-leave_document" class="form-control form-control-alternative{{ $errors->has('leave_document') ? ' is-invalid' : '' }}" >
</div>
<div class="form-group{{ $errors->has('reason') ? ' has-danger' : '' }}">
<label class="form-control-label" for="input-reason">{{ __('Reason') }}</label>
<input type="text" name="reason" id="input-reason" class="form-control form-control-alternative{{ $errors->has('reason') ? ' is-invalid' : '' }}" placeholder="{{ __('Reason') }}" required autofocus>
@if ($errors->has('reason'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('reason') }}</strong>
</span>
@endif
</div>
<div class="form-group{{ $errors->has('start') ? ' has-danger' : '' }}">
<label class="form-control-label" for="input-start">{{ __('Start date') }}</label>
<input type="date" name="start" id="input-start" class="form-control form-control-alternative{{ $errors->has('start') ? ' is-invalid' : '' }}" placeholder="{{ __('Start date') }}" autofocus>
@if ($errors->has('start'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('start') }}</strong>
</span>
@endif
</div>
<div class="form-group{{ $errors->has('end') ? ' has-danger' : '' }}">
<label class="form-control-label" for="input-end">{{ __('End date') }}</label>
<input type="date" name="end" id="input-end" class="form-control form-control-alternative{{ $errors->has('end') ? ' is-invalid' : '' }}" placeholder="{{ __('End date') }}" autofocus>
@if ($errors->has('end'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('end') }}</strong>
</span>
@endif
</div>
<div class="form-group{{ $errors->has('category') ? ' has-danger' : '' }}">
<label class="form-control-label" for="input-category">{{ __('Category') }}</label>
<select name="category" id="input-category" class="form-control form-control-alternative{{ $errors->has('category') ? ' is-invalid' : '' }}" placeholder="{{ __('Category') }}" autofocus>
<option value="full day">Full day</option>
<option value="half day">Half day</option>
<option value="short leave">Short leave</option>
</select>
@if ($errors->has('category'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('category') }}</strong>
</span>
@endif
</div>
<div class="form-group{{ $errors->has('type') ? ' has-danger' : '' }}">
<label class="form-control-label" for="input-type">{{ __('Type') }}</label>
<select name="type" id="input-type" class="form-control form-control-alternative{{ $errors->has('type') ? ' is-invalid' : '' }}" placeholder="{{ __('Type') }}" autofocus>
<option value="no pay">No pay</option>
<option value="casual">Casual</option>
</select>
@if ($errors->has('type'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('type') }}</strong>
</span>
@endif
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary mt-4">{{ __('Save') }}</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
var leave_id = @json($leaveid);
var val = @json('add');
if(leave_id!=val){
var values=@json($leave_req);
$("#input-reason").val(values.reason);
$("#input-start").val(values.start);
$("#input-end").val(values.end);
$("#input-category").val(values.category);
$("#input-type").val(values.type);
}
$("#input-leave_id").val(leave_id);
});
</script>
@include('layouts.footers.auth')
</div>
@endsection
@push('js')
<script src="{{ asset('argon') }}/vendor/chart.js/dist/Chart.min.js"></script>
<script src="{{ asset('argon') }}/vendor/chart.js/dist/Chart.extension.js"></script>
@endpush
<?php
namespace App\Http\Controllers;
use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Uuid;
class LeaveRequestController extends Controller
{
/**
* Show the application dashboard.
*
* @return \Illuminate\View\View
*/
public function index()
{
$id = auth()->id();
$leave_requests = DB::table('leave_requests')->where('request_by', '=', $id)->get();
$to_approve = DB::table('leave_requests')->where('approved_by', '=', $id)->get();
return view('leave.view', compact('leave_requests','to_approve'));
}
public static function get_user_name($user_id)
{
$user_=DB::table('users')->select('name')->where([['id', '=', $user_id],])->first();
return $user_;
}
public static function reject(Request $request)
{
$leaveid=$request->requestId;
DB::table('leave_requests')->where('id', '=', $leaveid)->update(['status' =>'rejected']);
return redirect()->to('/leave');
}
public static function approve(Request $request)
{
$leaveid=$request->requestId;
DB::table('leave_requests')->where('id', '=', $leaveid)->update(['status' => 'approved']);
return redirect()->to('/leave');
}
/**
* Store new events.
*
* @return \Illuminate\View\View
* @param \App\Http\Request $request
*/
public function store(Request $request)
{
$id = auth()->id();
$doc = $request->file('leave_document');
$manager_supervisor = DB::table('users')->where('id', '=', $id)->first();
if($doc!=null){
$uuid = Uuid::generate()->string;
$leave_doc_name = $uuid.'.'.$doc->getClientOriginalExtension();
$folder = '/uploads/leave_documents/';
$filePath = $folder . $leave_doc_name;
$this->uploadOne($doc, $folder, 'public', $leave_doc_name);
}else{
$leave_doc_name =null;
}
if($request->leave_id_=="add"){
DB::table('leave_requests')->insert([
[
'document_id'=>$leave_doc_name,
'reason' => $request->reason,
'start' =>$request->start,
'end'=>$request->end,
'request_by'=>$id,
'approved_by'=>$manager_supervisor->supervisor_manager,
'status'=>"pending",
'category'=>$request->category,
'type'=>$request->type,
'created_at'=>now(),
],
]);
}else{
DB::table('leave_requests')->where('id', '=', $request->leave_id_)->update(
array(
'document_id'=>$leave_doc_name,
'reason' => $request->reason,
'start' =>$request->start,
'end'=>$request->end,
'request_by'=>$id,
'approved_by'=>$manager_supervisor->supervisor_manager,
'category'=>$request->category,
'type'=>$request->type,
'updated_at'=>now(),
)
);
}
return redirect()->route('leave')->withStatus(__('Leave request successfully updated.'));
}
public static function destroy(Request $request)
{
$leaveid=$request->requestId;
DB::table('leave_requests')->where('id', '=', $leaveid)->delete();
return redirect()->to('/leave');
}
public function index2(Request $request)
{
$leaveid=$request->requestId;
if($leaveid=="add"){
$leave_req =null;
}else{
$leave_req = DB::table('leave_requests')->where('id', '=', $leaveid)->first();
}
return view('leave.add_edit',compact('leaveid','leave_req'));
}
public function uploadOne(UploadedFile $uploadedFile, $folder = null, $disk = 'public', $filename = null)
{
$name = !is_null($filename) ? $filename : Str::random(25);
$path =storage_path('uploads/leave_documents/'.$filename.'');
if( Storage::exists($path)){
Storage::disk('public')->delete('uploads/leave_documents/'.$filename.'');
}
$file = $uploadedFile->storeAs($folder, $name, $disk);
return $file;
}
/**
* Store new events.
*
* @return \Illuminate\View\View
*
*/
public function download_file($file_name)
{
return response()->download(storage_path("app/public/uploads/leave_documents/{$file_name}"));
}
}
Также в моем проекте есть другие формы с функцией загрузки документов, которые работают нормально. Я ищу везде решение, также я удаляю composer .lock файл, каталог производителя и запускаю composer install, composer update снова. а также запустить очистить кеш, сбросить команды автозагрузки тоже. также проверьте в папке vendor файлы подсветки / поддержки, и они существуют.
Я не знаю, что еще делать, пожалуйста, помогите!
мои миграции,
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateLeaveRequestsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('leave_requests', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('document_id')->nullable();
$table->string('reason');
$table->date('start');
$table->date('end');
$table->bigInteger('request_by')->unsigned();//emp_id
$table->bigInteger('approved_by')->unsigned()->nullable();//emp_id
$table->enum('status', ['approved','rejected','pending'])->default('pending');
$table->enum('category', ['full day','half day','short leave'])->default('full day');
$table->enum('type', ['no pay','casual'])->default('casual');
$table->timestamps();
$table->foreign('request_by')->references('id')->on('users');
$table->foreign('approved_by')->references('id')->on('users');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('leave_requests');
}
}
и
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateExpenseClaimTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('expense_claim', function (Blueprint $table) {
$table->bigIncrements('claim_id');
$table->date('date');
$table->String('reason');
$table->double('amount',10,2);
$table->String('bill_id');
$table->bigInteger('request_by')->unsigned();//emp_id
$table->bigInteger('approved_by')->unsigned();//emp_id
$table->enum('status', ['approved','rejected','pending'])->default('pending');
$table->timestamps();
$table->foreign('request_by')->references('id')->on('users');
$table->foreign('approved_by')->references('id')->on('users');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('expense_claim');
}
}