本文整理汇总了PHP中app\models\Company::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Company::find方法的具体用法?PHP Company::find怎么用?PHP Company::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Company
的用法示例。
在下文中一共展示了Company::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCompany
public function actionCompany()
{
$company = Company::find()->one();
if (empty($company)) {
$company = new Company();
$company->vat = 0;
$company->logo = '';
}
$post = Yii::$app->request->post();
if (!empty($post)) {
if (!empty($_FILES['Company']['name']['logo'])) {
$tmp_name = $_FILES['Company']['tmp_name']['logo'];
$name = $_FILES['Company']['name']['logo'];
if (file_exists('upload/' . $name)) {
unlink('upload' . $name);
}
if (move_uploaded_file($tmp_name, 'upload/' . $name)) {
$company->logo = $name;
}
}
$company->name = $post['Company']['name'];
$company->tax_code = $post['Company']['tax_code'];
$company->tel = $post['Company']['tel'];
$company->website = $post['Company']['website'];
$company->address = $post['Company']['address'];
$company->vat = $post['Company']['vat'];
if ($company->save()) {
$session = new Session();
$session->setFlash('message', 'บันทึกรายการแล้ว');
return $this->redirect(['company']);
}
}
return $this->render('//config/company', ['company' => $company]);
}
示例2: getCompaniesLogo
private function getCompaniesLogo()
{
$organisators = Company::find()->where(['is_organisator' => '1'])->orderBy('order')->all();
$organisatorsAndMembers = [];
foreach ($organisators as $value) {
$organisatorsAndMembers[$value->attributes['id']]['name'] = $value->attributes['name'];
if ($value->attributes['logo_url'] != '') {
$organisatorsAndMembers[$value->attributes['id']]['url'] = 'http://' . Yii::$app->request->serverName . $value->attributes['logo_url'];
} else {
$organisatorsAndMembers[$value->attributes['id']]['url'] = 'http://' . Yii::$app->request->serverName . '/files/logo/no_logo.jpg';
}
$organisatorsAndMembers[$value->attributes['id']]['intro'] = $value->attributes['intro_' . Yii::$app->language];
$organisatorsAndMembers[$value->attributes['id']]['site'] = $value->attributes['site'];
}
$members = Company::find()->where(['is_sponsor' => '1'])->orderBy('order')->all();
foreach ($members as $value) {
$organisatorsAndMembers[$value->attributes['id']]['name'] = $value->attributes['name'];
if ($value->attributes['logo_url'] != '') {
$organisatorsAndMembers[$value->attributes['id']]['url'] = 'http://' . Yii::$app->request->serverName . $value->attributes['logo_url'];
} else {
$organisatorsAndMembers[$value->attributes['id']]['url'] = 'http://' . Yii::$app->request->serverName . '/files/logo/no_logo.jpg';
}
$organisatorsAndMembers[$value->attributes['id']]['intro'] = $value->attributes['intro_' . Yii::$app->language];
$organisatorsAndMembers[$value->attributes['id']]['site'] = $value->attributes['site'];
}
return $organisatorsAndMembers;
}
示例3: actionIndex
public function actionIndex()
{
$query = Company::find();
//var_dump($query);die;
$pagination = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]);
$row = $query->offset($pagination->offset)->limit($pagination->limit)->all();
return $this->renderPartial('index', ['data' => $row, 'pagination' => $pagination]);
}
示例4: up
public function up()
{
$companys = Company::find()->All();
foreach ($companys as $company) {
//update payment,config
$this->insert($company->prefix . 'paymentType', ['id' => 8, 'name' => 'PayPal', 'value' => '\\app\\components\\payments\\Cash', 'oppt_account_id' => 12]);
$this->insert($company->prefix . 'accounts', ["id" => 12, "type" => 4, 'name' => 'PayPal', 'src_tax' => 0]);
$this->update($company->prefix . 'files', ['parent_type' => '\\app\\models\\docs'], ['parent_type' => "Docs"]);
$this->update($company->prefix . 'files', ['parent_type' => '\\app\\models\\Accounts'], ['parent_type' => "Accounts"]);
}
return true;
}
示例5: edit
public function edit($id)
{
if (Auth::user()->can('update-equipment')) {
$data['equipment'] = Equipment::find($id);
$data['title'] = $data['equipment']->company->name . " - Equipment " . $data['equipment']->name;
$data['equipment_types'] = EquipmentType::orderBy("name")->get();
$data['company'] = Company::find($data['equipment']->company_id);
$data['company']->company_id = $data['company']->id;
return view('equipment/edit', $data);
} else {
return redirect()->back()->withErrors(['Access denied to equipment edit page']);
}
}
示例6: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Company::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id]);
$query->andFilterWhere(['like', 'companyname', $this->companyname])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'contact', $this->contact])->andFilterWhere(['like', 'taxation_number', $this->taxation_number]);
return $dataProvider;
}
示例7: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Company::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id]);
$query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'email', $this->email]);
return $dataProvider;
}
示例8: up
public function up()
{
$companys = Company::find()->All();
foreach ($companys as $company) {
//update payment,config
$table = Yii::$app->db->schema->getTableSchema($company->prefix . 'accHist');
if (!isset($table->columns['subject'])) {
$this->addColumn($company->prefix . 'accHist', 'subject', 'VARCHAR(255)');
$this->addColumn($company->prefix . 'accHist', 'status', 'INTEGER(11)');
$this->addColumn($company->prefix . 'accHist', 'type', 'INTEGER(11)');
}
}
return true;
}
示例9: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Company::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'uid' => Yii::$app->user->id]);
$query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'addr', $this->addr]);
return $dataProvider;
}
示例10: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Company::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'need_presentation' => $this->need_presentation, 'need_training' => $this->need_training, 'pay_agree' => $this->pay_agree, 'is_organisator' => $this->is_organisator, 'is_sponsor' => $this->is_sponsor, 'order' => $this->order]);
$query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'ideas', $this->ideas])->andFilterWhere(['like', 'contact_person', $this->contact_person])->andFilterWhere(['like', 'telephone', $this->telephone])->andFilterWhere(['like', 'e_mail', $this->e_mail])->andFilterWhere(['like', 'site', $this->site])->andFilterWhere(['like', 'skype', $this->skype])->andFilterWhere(['like', 'logo_url', $this->logo_url])->andFilterWhere(['like', 'intro_uk', $this->intro_uk])->andFilterWhere(['like', 'intro_ru', $this->intro_ru])->andFilterWhere(['like', 'intro_en', $this->intro_en])->andFilterWhere(['like', 'facebook_profile', $this->facebook_profile])->andFilterWhere(['like', 'google_profile', $this->google_profile])->andFilterWhere(['like', 'linkedin_profile', $this->linkedin_profile])->andFilterWhere(['like', 'vk_profile', $this->vk_profile]);
return $dataProvider;
}
示例11: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Company::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'pricipal_id' => $this->pricipal_id]);
$query->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'addr', $this->addr])->andFilterWhere(['like', 'intro', $this->intro])->andFilterWhere(['like', 'tel', $this->tel])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'comment', $this->comment]);
return $dataProvider;
}
示例12: actionGetCard
public function actionGetCard($cid)
{
$company = Company::find()->where(['id' => $cid])->asArray()->one();
$address = Address::find()->where(['id' => $company['address_id']])->asArray()->one();
$shedule = Shedule::find()->where(['company_id' => $cid])->asArray()->all();
$brand = Company::find()->where(['id' => $cid])->one()->brand;
$service = Company::find()->where(['id' => $cid])->one()->service;
$srv = ArrayHelper::getColumn($service, 'category_id');
$category = Category::find()->where(['id' => $srv])->asArray()->indexBy('id')->all();
$srv = ArrayHelper::map($service, 'id', 'name', 'category_id');
$spoffer = SpecialOffer::find()->where(['company_id' => $cid])->asArray()->one();
$file = Files::find()->where(['id' => $spoffer['file_id']])->asArray()->one();
Yii::$app->response->format = Response::FORMAT_JSON;
$response = ['company' => $company, 'address' => $address, 'shedule' => $shedule, 'brand' => $brand, 'category' => $category, 'service' => $srv, 'spoffer' => $spoffer, 'file' => $file];
return $response;
}
示例13: edit_submit
public function edit_submit()
{
$data = \Request::all();
$company = Company::find(\Request::input('company_id'));
$company->name = $data['name'];
if (isset($data['image'])) {
$file_name = \Common::get_img_filename($data['image']);
\Common::make_square_img($file_name, 140);
$res = \Common::s3_upload($file_name, 'company/');
if ($res['success']) {
$company->ci = $res['filename'];
}
}
$company->status = $data['status_group'];
$company->save();
return \Redirect()->action('CompanyController@index');
}
示例14: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$admin_id = Yii::$app->user->identity->id;
$query = Company::find();
if (Yii::$app->user->identity->type == 'normal') {
$query = $query->innerJoin('wolf_admin_to_company wc', 'wc.company_id=wolf_company.company_id');
$query = $query->where('admin_id=' . $admin_id);
}
$dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['company_id' => SORT_DESC]]]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['company_id' => $this->company_id]);
$query->andFilterWhere(['like', 'company_name', $this->company_name])->andFilterWhere(['like', 'company_email', $this->company_email])->andFilterWhere(['like', 'company_contact', $this->company_contact])->andFilterWhere(['like', 'company_address', $this->company_address])->andFilterWhere(['like', 'account_no', $this->account_no])->andFilterWhere(['like', 'payment_terms', $this->payment_terms])->andFilterWhere(['like', 'rate', $this->rate])->andFilterWhere(['like', 'person_in_charge', $this->person_in_charge]);
return $dataProvider;
}
示例15: actionIndex
public function actionIndex()
{
$company = Company::find()->orderBy('id')->one();
if (!empty($_POST)) {
if (!empty($_FILES['Company'])) {
// remove old logo
if (!empty($company->logo)) {
$old_img = $company->logo;
unlink('../uploads/' . $old_img);
}
// upload new logo
$img = $_FILES['Company']['name']['logo'];
$ext = end(explode(".", $img));
$name = microtime();
$name = str_replace(' ', '', $name);
$name = str_replace('.', '', $name);
$name = $name . '.' . $ext;
$tmp = $_FILES['Company']['tmp_name']['logo'];
$company->logo = $name;
move_uploaded_file($tmp, '../uploads/' . $name);
}
$company->name = $_POST['Company']['name'];
$company->web_title = $_POST['Company']['web_title'];
$company->tel = $_POST['Company']['tel'];
$company->email = $_POST['Company']['email'];
$company->fax = $_POST['Company']['fax'];
$company->website = $_POST['Company']['website'];
$company->facebook = $_POST['Company']['facebook'];
$company->line_id = $_POST['Company']['line_id'];
$company->address = $_POST['Company']['address'];
$company->tax_code = $_POST['Company']['tax_code'];
$company->payment = $_POST['Company']['payment'];
$company->about = $_POST['Company']['about'];
if ($company->save()) {
$session = new Session();
$session->open();
$session->setFlash('message', 'Data Saved.');
return $this->redirect(['index']);
}
}
return $this->render('//Company/Index', ['company' => $company]);
}