mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-07 03:47:32 -08:00
Merge remote-tracking branch 'origin/develop'
This commit is contained in:
commit
1c02a7d590
|
@ -29,6 +29,7 @@ class CompaniesController extends Controller
|
||||||
'name',
|
'name',
|
||||||
'phone',
|
'phone',
|
||||||
'fax',
|
'fax',
|
||||||
|
'email',
|
||||||
'created_at',
|
'created_at',
|
||||||
'updated_at',
|
'updated_at',
|
||||||
'users_count',
|
'users_count',
|
||||||
|
@ -49,6 +50,10 @@ class CompaniesController extends Controller
|
||||||
$companies->where('name', '=', $request->input('name'));
|
$companies->where('name', '=', $request->input('name'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($request->filled('email')) {
|
||||||
|
$companies->where('email', '=', $request->input('email'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Make sure the offset and limit are actually integers and do not exceed system limits
|
// Make sure the offset and limit are actually integers and do not exceed system limits
|
||||||
$offset = ($request->input('offset') > $companies->count()) ? $companies->count() : abs($request->input('offset'));
|
$offset = ($request->input('offset') > $companies->count()) ? $companies->count() : abs($request->input('offset'));
|
||||||
|
@ -168,6 +173,7 @@ class CompaniesController extends Controller
|
||||||
$companies = Company::select([
|
$companies = Company::select([
|
||||||
'companies.id',
|
'companies.id',
|
||||||
'companies.name',
|
'companies.name',
|
||||||
|
'companies.email',
|
||||||
'companies.image',
|
'companies.image',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@ final class CompaniesController extends Controller
|
||||||
$company->name = $request->input('name');
|
$company->name = $request->input('name');
|
||||||
$company->phone = $request->input('phone');
|
$company->phone = $request->input('phone');
|
||||||
$company->fax = $request->input('fax');
|
$company->fax = $request->input('fax');
|
||||||
|
$company->email = $request->input('email');
|
||||||
|
|
||||||
$company = $request->handleImages($company);
|
$company = $request->handleImages($company);
|
||||||
|
|
||||||
|
@ -115,6 +116,7 @@ final class CompaniesController extends Controller
|
||||||
$company->name = $request->input('name');
|
$company->name = $request->input('name');
|
||||||
$company->phone = $request->input('phone');
|
$company->phone = $request->input('phone');
|
||||||
$company->fax = $request->input('fax');
|
$company->fax = $request->input('fax');
|
||||||
|
$company->email = $request->input('email');
|
||||||
|
|
||||||
$company = $request->handleImages($company);
|
$company = $request->handleImages($company);
|
||||||
|
|
||||||
|
@ -123,8 +125,7 @@ final class CompaniesController extends Controller
|
||||||
->with('success', trans('admin/companies/message.update.success'));
|
->with('success', trans('admin/companies/message.update.success'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->route('companies.edit', ['company' => $companyId])
|
return redirect()->back()->withInput()->withErrors($company->getErrors());
|
||||||
->with('error', trans('admin/companies/message.update.error'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -28,6 +28,7 @@ class CompaniesTransformer
|
||||||
'name' => e($company->name),
|
'name' => e($company->name),
|
||||||
'phone' => ($company->phone!='') ? e($company->phone): null,
|
'phone' => ($company->phone!='') ? e($company->phone): null,
|
||||||
'fax' => ($company->fax!='') ? e($company->fax): null,
|
'fax' => ($company->fax!='') ? e($company->fax): null,
|
||||||
|
'email' => ($company->email!='') ? e($company->email): null,
|
||||||
'image' => ($company->image) ? Storage::disk('public')->url('companies/'.e($company->image)) : null,
|
'image' => ($company->image) ? Storage::disk('public')->url('companies/'.e($company->image)) : null,
|
||||||
'created_at' => Helper::getFormattedDateObject($company->created_at, 'datetime'),
|
'created_at' => Helper::getFormattedDateObject($company->created_at, 'datetime'),
|
||||||
'updated_at' => Helper::getFormattedDateObject($company->updated_at, 'datetime'),
|
'updated_at' => Helper::getFormattedDateObject($company->updated_at, 'datetime'),
|
||||||
|
|
|
@ -24,6 +24,9 @@ final class Company extends SnipeModel
|
||||||
// Declare the rules for the model validation
|
// Declare the rules for the model validation
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
'name' => 'required|min:1|max:255|unique:companies,name',
|
'name' => 'required|min:1|max:255|unique:companies,name',
|
||||||
|
'fax' => 'min:7|max:35|nullable',
|
||||||
|
'phone' => 'min:7|max:35|nullable',
|
||||||
|
'email' => 'email|max:150|nullable',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $presenter = \App\Presenters\CompanyPresenter::class;
|
protected $presenter = \App\Presenters\CompanyPresenter::class;
|
||||||
|
@ -45,7 +48,7 @@ final class Company extends SnipeModel
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $searchableAttributes = ['name', 'phone', 'fax', 'created_at', 'updated_at'];
|
protected $searchableAttributes = ['name', 'phone', 'fax', 'email', 'created_at', 'updated_at'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The relations and their attributes that should be included when searching the model.
|
* The relations and their attributes that should be included when searching the model.
|
||||||
|
@ -63,6 +66,7 @@ final class Company extends SnipeModel
|
||||||
'name',
|
'name',
|
||||||
'phone',
|
'phone',
|
||||||
'fax',
|
'fax',
|
||||||
|
'email',
|
||||||
];
|
];
|
||||||
|
|
||||||
private static function isFullMultipleCompanySupportEnabled()
|
private static function isFullMultipleCompanySupportEnabled()
|
||||||
|
|
|
@ -45,6 +45,14 @@ class CompanyPresenter extends Presenter
|
||||||
'title' => trans('admin/suppliers/table.fax'),
|
'title' => trans('admin/suppliers/table.fax'),
|
||||||
'visible' => false,
|
'visible' => false,
|
||||||
'formatter' => 'phoneFormatter',
|
'formatter' => 'phoneFormatter',
|
||||||
|
], [
|
||||||
|
'field' => 'email',
|
||||||
|
'searchable' => true,
|
||||||
|
'sortable' => true,
|
||||||
|
'switchable' => true,
|
||||||
|
'title' => trans('admin/suppliers/table.email'),
|
||||||
|
'visible' => true,
|
||||||
|
'formatter' => 'emailFormatter',
|
||||||
], [
|
], [
|
||||||
'field' => 'image',
|
'field' => 'image',
|
||||||
'searchable' => false,
|
'searchable' => false,
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddEmailToCompanies extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('companies', function (Blueprint $table) {
|
||||||
|
$table->string('email', 150)->after('fax')->nullable()->default(null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('companies', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('email');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@
|
||||||
@include ('partials.forms.edit.name', ['translated_name' => trans('admin/companies/table.name')])
|
@include ('partials.forms.edit.name', ['translated_name' => trans('admin/companies/table.name')])
|
||||||
@include ('partials.forms.edit.phone')
|
@include ('partials.forms.edit.phone')
|
||||||
@include ('partials.forms.edit.fax')
|
@include ('partials.forms.edit.fax')
|
||||||
|
@include ('partials.forms.edit.email')
|
||||||
@include ('partials.forms.edit.image-upload', ['image_path' => app('companies_upload_path')])
|
@include ('partials.forms.edit.image-upload', ['image_path' => app('companies_upload_path')])
|
||||||
|
|
||||||
@stop
|
@stop
|
||||||
|
|
Loading…
Reference in a new issue