Company logo added media manager
This commit is contained in:
@ -59,9 +59,16 @@ class Companies extends Controller
|
||||
setting()->set('general.company_email', $request->get('company_email'));
|
||||
setting()->set('general.company_address', $request->get('company_address'));
|
||||
|
||||
$logo_path = $this->getUploadedFilePath($request->file('company_logo'), 'settings', $company->id);
|
||||
if ($logo_path) {
|
||||
setting()->set('general.company_logo', $logo_path);
|
||||
if ($request->file('company_logo')) {
|
||||
$logo = $this->getMedia($request->file('company_logo'), 'settings', $company->id);
|
||||
|
||||
if ($logo) {
|
||||
$company->attachMedia($logo, 'logo');
|
||||
|
||||
$logo_path = $logo->directory . '/' . $logo->basename;
|
||||
|
||||
setting()->set('general.company_logo', $logo_path);
|
||||
}
|
||||
}
|
||||
|
||||
setting()->set('general.default_currency', $request->get('default_currency'));
|
||||
@ -135,9 +142,16 @@ class Companies extends Controller
|
||||
setting()->set('general.company_email', $request->get('company_email'));
|
||||
setting()->set('general.company_address', $request->get('company_address'));
|
||||
|
||||
$logo_path = $this->getUploadedFilePath($request->file('company_logo'), 'settings', $company->id);
|
||||
if ($logo_path) {
|
||||
setting()->set('general.company_logo', $logo_path);
|
||||
if ($request->file('company_logo')) {
|
||||
$logo = $this->getMedia($request->file('company_logo'), 'settings', $company->id);
|
||||
|
||||
if ($logo) {
|
||||
$company->attachMedia($logo, 'logo');
|
||||
|
||||
$logo_path = $logo->directory . '/' . $logo->basename;
|
||||
|
||||
setting()->set('general.company_logo', $logo_path);
|
||||
}
|
||||
}
|
||||
|
||||
setting()->set('general.default_payment_method', 'offlinepayment.cash.1');
|
||||
|
@ -7,10 +7,11 @@ use EloquentFilter\Filterable;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Kyslik\ColumnSortable\Sortable;
|
||||
use Plank\Mediable\Mediable;
|
||||
|
||||
class Company extends Eloquent
|
||||
{
|
||||
use Filterable, SoftDeletes, Sortable;
|
||||
use Filterable, SoftDeletes, Sortable, Mediable;
|
||||
|
||||
protected $table = 'companies';
|
||||
|
||||
@ -229,4 +230,18 @@ class Company extends Eloquent
|
||||
->orderBy('value', $direction)
|
||||
->select('companies.*');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current balance.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLogoAttribute()
|
||||
{
|
||||
if (!$this->hasMedia('logo')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->getMedia('logo')->last();
|
||||
}
|
||||
}
|
||||
|
@ -30,8 +30,14 @@ trait Uploads
|
||||
return $path;
|
||||
}
|
||||
|
||||
public function getMedia($file, $folder, $company_id = null)
|
||||
public function getMedia($file, $folder = 'settings', $company_id = null)
|
||||
{
|
||||
$path = '';
|
||||
|
||||
if (!$file || !$file->isValid()) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
if (!$company_id) {
|
||||
$company_id = session('company_id');
|
||||
}
|
||||
|
Reference in New Issue
Block a user