Диплом: Автоматизация учета аренды площадей клиентами компании ООО "Грандтитул"

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
107
->when($onlyMy,function($query)use($onlyMy){
return$query->where('agent_id',Auth::user()->id);
})
->limit(15)
->paginate(15);
}
}
<?php
namespaceApp\Http\Controllers;
useApp\Http\Requests\OrderRequest;
useApp\Order;
useApp\OrderStatus;
useIlluminate\Http\Request;
useApp\Operation;
useIlluminate\Support\Facades\Auth;
classOrderControllerextendsController
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
publicfunctionindex()
{
returnview('order.index',['backToFront'=>[
'operations'=>Operation::all(),
'statuses'=>OrderStatus::all()
]]);
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
publicfunctioncreate()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
publicfunctionstore(OrderRequest$request)
{
$toFill=$request->all();
$toFill['agent_id']=$request->user()->id;
$order=Order::create($toFill);
returnjson_encode(['success'=>true,'added'=>$order]);
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
publicfunctionshow($id)
{
108
//
}
/**
* Обновлениеспецифичноймодели
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
publicfunctionupdate(OrderRequest$request,$id)
{
$order=Order::findOrFail($id);
$toFill=$request->all();
$toFill['agent_id']=$request->user()->id;
$order->fill($toFill);
$order->save();
returnjson_encode(['success'=>true,'updated'=>$order]);
}
/**
* Удаление специфичной модели
*
* @param int $id
* @return \Illuminate\Http\Response
*/
publicfunctiondestroy($id)
{
$client=Order::findOrFail($id);
$client->delete();
returnjson_encode(['success'=>true,'deleted'=>$id]);
}
publicfunctionsearch(Request$request){
$searchField=$request->client_field;
$createdAtField=$request->created_at_field;
$operationField=$request->operation_field;
$statusField=$request->status_field;
$agentField=$request->agent_field;
$onlyMy=$request->only_my;
returnOrder::with('status','operation','agent','client')
->when($operationField,function($query)use($operationField){
return$query->where('operation_id',$operationField);
})
->when($statusField,function($query)use($statusField){
return$query->where('order_status_id',$statusField);
})
->when($createdAtField,function($query)use($createdAtField){
$explodedCreated=explode(',',$createdAtField);
switch(count($explodedCreated)){
case2:
return$query->whereBetween('created_at',[$explodedCreated[0],$explodedCreated[1]]);
case1:
109
return$query->where('created_at','>=',$explodedCreated[0]);
default:
returnfalse;
}
})
->when($searchField,function($query)use($searchField){
return$query
->where(function($query)use($searchField){
$query->where('f_name','like','%'.$searchField.'%')
->orWhere('m_name','like','%'.$searchField.'%')
->orWhere('l_name','like','%'.$searchField.'%')
->orWhere('id','like','%'.$searchField.'%');
});
})
->when($agentField,function($query)use($agentField){
$queryTwo="clients.id like '%".$agentField."%' OR "
."clients.f_name like '%".$agentField."%' OR "
."clients.l_name like '%".$agentField."%' OR"
."clients.m_name like '%".$agentField."%'"
."";
return$query->whereExists(function($query)use($queryTwo){
$query->select(DB::raw('id, f_name, l_name, m_name'))
->from('clients')
->whereRaw($queryTwo);
});
})
->when($onlyMy,function($query)use($onlyMy){
return$query->where('agent_id',Auth::user()->id);
})
->limit(15)
->paginate(15);
}
}
<?php
namespaceApp;
useIlluminate\Database\Eloquent\Model;
classBuildingextendsModel
{
protected$guarded=[];
//relations
publicfunctiontype(){
return$this->belongsTo('App\BuildingType','building_type_id');
}
publicfunctionoperation(){
return$this->belongsTo('App\Operation');
}
publicfunctionclient(){
return$this->belongsTo('App\Client');
}
}
<?php
namespaceApp;
useIlluminate\Database\Eloquent\Model;
110
classClientextendsModel
{
protected$guarded=[];
//relation
publicfunctionmembers(){
return$this->hasMany('App\Members');
}
publicfunctionbuildings(){
return$this->hasMany('App\Building');
}
}
<?php
namespaceApp;
useIlluminate\Database\Eloquent\Model;
classContractextendsModel
{
protected$guarded=[];
//relations
publicfunctiontype(){
return$this->belongsTo('App\ContractType');
}
publicfunctionorder(){
return$this->belongsTo('App\Order');
}
publicfunctionbuilding(){
return$this->belongsTo('App\Building');
}
publicfunctionmembers(){
return$this->hasMany('App\Members');
}
}
<?php
namespaceApp;
useIlluminate\Database\Eloquent\Model;
classOperationextendsModel
{
protected$guarded=[];
publicfunctionbuildings(){
return$this->hasMany('App\Building');
}
}
<?php
namespaceApp;
useIlluminate\Database\Eloquent\Model;
classOrderextendsModel
{
protected$guarded=[];
publicfunctionclient(){
111
return$this->belongsTo('App\Client');
}
publicfunctionoperation(){
return$this->belongsTo('App\Operation');
}
publicfunctionstatus(){
return$this->belongsTo('App\OrderStatus','order_status_id');
}
publicfunctionagent(){
return$this->belongsTo('App\Agent');
}
}
<?php
useIlluminate\Support\Facades\Schema;
useIlluminate\Database\Schema\Blueprint;
useIlluminate\Database\Migrations\Migration;
classCreateTableBuildingTypesextendsMigration
{
/**
* Run the migrations.
*
* @return void
*/
publicfunctionup()
{
Schema::create('building_types',function(Blueprint$table){
$table->increments('id');
$table->string('title',100);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
publicfunctiondown()
{
Schema::dropIfExists('building_types');
}
}
<?php
useIlluminate\Support\Facades\Schema;
useIlluminate\Database\Schema\Blueprint;
useIlluminate\Database\Migrations\Migration;
classCreateTableOperationsextendsMigration
{
/**
* Run the migrations.
*
* @return void
*/
publicfunctionup()
112
{
Schema::create('operations',function(Blueprint$table){
$table->increments('id');
$table->string('title',100);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
publicfunctiondown()
{
Schema::dropIfExists('operations');
}
}
<?php
useIlluminate\Support\Facades\Schema;
useIlluminate\Database\Schema\Blueprint;
useIlluminate\Database\Migrations\Migration;
classCreateTableClientsextendsMigration
{
/**
* Run the migrations.
*
* @return void
*/
publicfunctionup()
{
Schema::create('clients',function(Blueprint$table){
$table->increments('id');
$table->string('l_name',100);
$table->string('f_name',100);
$table->string('m_name',100)->default("");
$table->integer('sex');
$table->string('address',100);
$table->string('phone',15);
$table->integer('fc');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
publicfunctiondown()
{
Schema::dropIfExists('clients');
}
}
<?php
useIlluminate\Support\Facades\Schema;
useIlluminate\Database\Schema\Blueprint;
useIlluminate\Database\Migrations\Migration;
classCreateTableBuildingextendsMigration
{
/**
* Run the migrations.
*
* @return void
113
*/
publicfunctionup()
{
Schema::create('buildings',function(Blueprint$table){
$table->increments('id');
$table->string("address",100);
$table->string("description",100);
$table->string("description2",100);
$table->integer("building_type_id")->unsigned();
$table->integer("operation_id")->unsigned();
$table->integer("client_id")->unsigned();
$table->double("sq");
$table->double("sq2");
$table->integer("count_room");
$table->double("price");
$table->integer("floor");
$table->integer("floor_all");
$table->timestamps();
$table->foreign('building_type_id')
->references('id')
->on('building_types')
->onUpdate('cascade')
->onDelete('no action');
$table->foreign('operation_id')
->references('id')
->on('operations')
->onUpdate('cascade')
->onDelete('no action');
$table->foreign('client_id')
->references('id')
->on('clients')
->onUpdate('cascade')
->onDelete('no action');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
publicfunctiondown()
{
Schema::table('buildings',function(Blueprint$table){
$table->dropForeign('buildings_building_type_id_foreign');
$table->dropForeign('buildings_operation_id_foreign');
$table->dropForeign('buildings_client_id_foreign');
});
Schema::dropIfExists('buildings');
}
}
<?php
useIlluminate\Support\Facades\Schema;
useIlluminate\Database\Schema\Blueprint;
useIlluminate\Database\Migrations\Migration;
classCreateTableOrdersextendsMigration
{
/**
* Run the migrations.
*
* @return void
*/
publicfunctionup()
{
Schema::create('orders',function(Blueprint$table){
$table->increments('id');
114
$table->string('description',100);
$table->integer('operation_id')->unsigned();
$table->integer('order_status_id')->unsigned();
$table->integer('agent_id')->unsigned();
$table->integer('client_id')->unsigned();
$table->timestamps();
$table->foreign('operation_id')
->references('id')
->on('operations')
->onUpdate('cascade')
->onDelete('no action');
$table->foreign('order_status_id')
->references('id')
->on('order_statuses')
->onUpdate('cascade')
->onDelete('no action');
$table->foreign('agent_id')
->references('id')
->on('agents')
->onUpdate('cascade')
->onDelete('no action');
$table->foreign('client_id')
->references('id')
->on('clients')
->onUpdate('cascade')
->onDelete('no action');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
publicfunctiondown()
{
Schema::table('orders',function(Blueprint$table){
$table->dropForeign('orders_order_status_id_foreign');
$table->dropForeign('orders_operation_id_foreign');
$table->dropForeign('orders_client_id_foreign');
$table->dropForeign('orders_agent_id_foreign');
});
Schema::dropIfExists('orders');
}
}
<?php
$app=newIlluminate\Foundation\Application(
realpath(__DIR__.'/../')
);
$app->singleton(
Illuminate\Contracts\Http\Kernel::class,
App\Http\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
App\Console\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
);
return$app;
115
window._=require('lodash');
window.Popper=require('popper.js').default;
try{
window.$=window.jQuery=require('jquery');
require('bootstrap');
}catch(e){}
window.axios=require('axios');
window.axios.defaults.headers.common['X-Requested-With']='XMLHttpRequest';
lettoken=document.head.querySelector('meta[name="csrf-token"]');
if(token){
window.axios.defaults.headers.common['X-CSRF-TOKEN']=token.content;
}else{
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-
token');
}
/**
* First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
*/
require('./bootstrap');
require('air-datepicker');
require('select2');
window.Vue=require('vue');
letVeeValidate=require('vee-validate');
window.VueValidateDictionaryRu=require('vee-validate/dist/locale/ru');
Vue.use(VeeValidate,{
locale:'ru',
dictionary:{
ru:{
messages:VueValidateDictionaryRu
}
}
});
/**
* Next, we will create a fresh Vue application instance and attach it to
* the page. Then, you may begin adding components to this application
* or customize the JavaScript scaffolding to fit your unique needs.
*/
//Vue.component('example-component', require('./components/ExampleComponent.vue'));
Vue.component('lister-component',require('./components/ListerComponent.vue'));
Vue.component('clients-list',require('./components/ClientsList.vue'));
Vue.component('clients-add',require('./components/ClientsAdd.vue'));
Vue.component('order-add',require('./components/OrderAdd.vue'));
Vue.component('order-list',require('./components/OrderList.vue'));
Vue.component('building-add',require('./components/BuildingAdd.vue'));
Vue.component('building-list',require('./components/BuildingList.vue'));
if($("#lister").length>0){
constlister=newVue({
el:'#lister',
data:{
listData:phpToVueData.listData,
model:phpToVueData.model,
name:phpToVueData.name
},
116
mounted(){
console.log('mounted');
}
});
}
if($("#clients").length>0){
constclients=newVue({
el:'#clients',
data:{
paginateData:{
current_page:1,
data:[],
first_page_url:"http://camobjects/cObjects/searcher?page=1",
from:null,
last_page:1,
last_page_url:"http://camobjects/cObjects/searcher?page=1",
next_page_url:null,
path:"http://camobjects/cObjects/searcher",
per_page:15,
prev_page_url:null,
to:null,
total:0
},
searchField:"",
createdAtField:"",
fcField:0,
searchCaption:"Укажите параметры поиска для зароса!",
searchCaptionClases:"alert alert-info",
finalCaption:"",
creating:false
},
computed:{
clientsBr:function(){
returnthis.paginateData.data;
},
},
watch:{
searchField:function(){
this.startSearch();
},
createdAtField:function(){
this.startSearch();
},
fcField:function(){
this.startSearch();
},
},
methods:{
startSearch:function(){
this.searchCaptionClases="alert alert-info";
this.searchCaption='Ожидаюокончанияввода';
this.getSearchResult();
},
createModel:function(){
this.creating=!this.creating;
},
cancelCreate:function(){
this.creating=false;
},
storeModel:function(model){
this.paginateData.data.unshift(model);
this.startAlert('Клиентдобавлен');
this.creating=false;
},
updateModel:function(model){
letfinalIndex=false;

Смотрите также:

"Автоматизация обработки заявок ООО "Проектно-Строительная Компания"
"Автоматизация процесса аттестации персонала для ООО "Нэт Бай Нэт Холдинг"
"Анализ интернет-активности конкурентов ( на примере конкурентов "Газпром нефть")
"Бухгалтерский учёт и аудит расчётов с подотчётними лицами в организации на примере ООО "ЛОЦ 10""
«Психологическое сопровождение персонала в организации на примере ООО «Крокус»
Cовершенствование деловой оценки персонала в организации (на примере ООО "Даймонд кейтеринг развитие")
IPO - инструмент финансирования деятельности организации. На примере ПАО «Нефтяная компания «Лукойл»
PR как средство продвижения организации (на примере ПАО "Тамбовский завод "Комсомолец им. Н.С. Артемова")
PR-коммуникации в сфере общественного питания (на примере кафе-кондитерской «Cream Cheese»)
SMM как средство повышения эффективности работы учреждений социокультурной сферы (на примере Малого театра)