%PDF- %PDF-
Direktori : /var/www/html/sljcon/resources/views/admin/project/ |
Current File : /var/www/html/sljcon/resources/views/admin/project/form.blade.php |
@extends('layouts.app') @section('content') <div class="container"> <div class="row"> <div class="col-md-12 m_top_30"> <form class="form-horizontal" method="POST" autocomplete="off" enctype="multipart/form-data" action="{{ route('admin.project.store', $id) }}"> {{ csrf_field() }} <div class="center m_top_30 m_bottom_30"> <h2>Add New Project</h2> </div> <div class="form-group"> @if ($errors->any()) <div class="alert alert-danger"> <ul> @foreach ($errors->all() as $error) <li>{{ $error }}</li> @endforeach </ul> </div> @endif </div> <div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}"> <label for="name" class="col-md-3 control-label">Name</label> <div class="col-md-6"> <input id="name" type="text" class="form-control" name="name" value="{{ $project->name?$project->name:old('name') }}" required autofocus> </div> </div> <div class="form-group{{ $errors->has('slug') ? ' has-error' : '' }}"> <label for="slug" class="col-md-3 control-label">Slug</label> <div class="col-md-6"> <input id="slug" type="text" class="form-control" name="slug" value="{{ $project->slug?$project->slug:old('slug') }}" required> </div> </div> @if(count($categories) > 0) <div class="form-group{{ $errors->has('category_id') ? ' has-error' : '' }}"> <label for="category_id" class="col-md-3 control-label">Category</label> <div class="col-md-6"> <select class="form-control" id="category_id" name="category_id"> <option value="">Category</option> @foreach($categories as $cat) <option value="{{$cat->id}}" {{$cat->id == $project->category_id ? 'selected' : ''}}> {{$cat->name}} </option> @endforeach </select> @if ($errors->has('parent_id')) <span class="help-block"> <strong>{{ $errors->first('parent_id') }}</strong> </span> @endif </div> </div> @endif <div class="form-group{{ $errors->has('short_description') ? ' has-error' : '' }}"> <label for="short_description" class="col-md-3 control-label">Description</label> <div class="col-md-6"> <textarea id="short_description" class="form-control" name="short_description" rows="6" required >{{ $project->short_description?$project->short_description:old('short_description') }}</textarea> @if ($errors->has('short_description')) <span class="help-block"> <strong>{{ $errors->first('short_description') }}</strong> </span> @endif </div> </div> <div class="form-group{{ $errors->has('order') ? ' has-error' : '' }}"> <label for="order" class="col-md-3 control-label">Order</label> <div class="col-md-6"> <input id="order" type="number" class="form-control" name="order" value="{{ $project->order?$project->order:old('order') }}" required> </div> </div> <div class="form-group{{ $errors->has('type') ? ' has-error' : '' }}"> <label for="order" class="col-md-3 control-label">Project Type</label> <div class="col-md-6"> <select class="form-control" id="project_type" name="project_type" onchange="projectTypeChange(this)"> <option selected disabled>Choose Type</option> <option value="1">Type 1 (318x318 px)</option> <option value="2">Type 2 (318x640 px)</option> <option value="3">Type 3 (640x318 px)</option> </select> </div> </div> <div class="form-group{{ $errors->has('start_date') ? ' has-error' : '' }}"> <label for="start_date" class="col-md-3 control-label">Started Date</label> <div class="col-md-6"> <input id="start_date" type="date" class="form-control" name="start_date" value="{{ $project->start_date?$project->start_date:old('start_date') }}" required> </div> </div> <div class="form-group{{ $errors->has('finish_date') ? ' has-error' : '' }}"> <label for="finish_date" class="col-md-3 control-label">Finish Date</label> <div class="col-md-6"> <input id="finish_date" type="date" class="form-control" name="finish_date" value="{{ $project->finish_date?$project->finish_date:old('finish_date') }}" required> </div> </div> <div class="form-group{{ $errors->has('work_hours') ? ' has-error' : '' }}"> <label for="work_hours" class="col-md-3 control-label">Work Hours</label> <div class="col-md-6"> <input id="work_hours" type="number" class="form-control" name="work_hours" value="{{ $project->work_hours?$project->work_hours:old('work_hours') }}" required> </div> </div> <div class="form-group{{ $errors->has('staff_number') ? ' has-error' : '' }}"> <label for="staff_number" class="col-md-3 control-label">Staff Number</label> <div class="col-md-6"> <input id="staff_number" type="number" class="form-control" name="staff_number" value="{{ $project->staff_number?$project->staff_number:old('staff_number') }}" required> </div> </div> <div class="form-group{{ $errors->has('file') ? ' has-error' : '' }}"> <label for="file" class="col-md-3 control-label" id='mainImageLabel'>Main Image</label> <div class="col-md-6"> <input type="file" name="file" id="file" accept="image/*" onchange="fileChanged(this)"> @if ($errors->has('file')) <span class="help-block"> <strong>{{ $errors->first('file') }}</strong> </span> @endif </div> </div> <div class="form-group"> <div class="col-md-6 col-md-offset-3"> @if($project->media()->count() > 0) <img class="img img-responsive full-width" id="image-preview-uploaded" src="{{env('APP_URL') . 'uploads/' . $project->media()->where('media_type', \App\Models\Media::MEDIA_TYPE_PROJECT_IMAGE)->first()->file_name}}"> @endif <img class="img img-responsive full-width" id="image-preview"> </div> </div> <div class="form-group"> <div class="col-md-8 col-md-offset-3"> <button type="submit" class="btn btn-primary"> Save </button> </div> </div> </form> </div> </div> </div> @endsection <script> function fileChanged(input) { if (input.files && input.files[0]) { var reader = new FileReader(); reader.onload = function (e) { $('#image-preview').attr('src', e.target.result); $('#image-preview-uploaded').css('display', 'none'); }; reader.readAsDataURL(input.files[0]); } } function projectTypeChange(input) { var label = $('#mainImageLabel'); var typeSelected = input.options[input.selectedIndex].text; typeSelected = typeSelected.substring(typeSelected.indexOf("("), typeSelected.indexOf(")") + 1); label.text('Main Image ' + typeSelected); } </script>