本文整理汇总了PHP中app\Contact::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Contact::with方法的具体用法?PHP Contact::with怎么用?PHP Contact::with使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Contact
的用法示例。
在下文中一共展示了Contact::with方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$contact = Contact::with(['societe' => function ($query) {
$query->select('nom_clt', 'id');
}])->where('etat', 1)->orderBy('nom_contact', 'asc')->get();
$actif = 'contact';
$type = 1;
return view('contact.contact', compact('actif', 'contact', 'type'));
}
示例2: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$contacts = new Contact();
$actif = 'contact';
$type = 1;
if (isset($_GET['sort'])) {
if ($_GET['sort'] == 'pays_clt') {
$contact = DB::table('contacts')->leftjoin('societes', 'contacts.societe_id', '=', 'societes.id')->orderBy('societes.pays_clt', $_GET['order'])->where('contacts.etat', 1)->get();
$tri = 'pays';
} elseif ($_GET['sort'] == 'statut') {
$contact = DB::table('contacts')->leftjoin('societes', 'contacts.societe_id', '=', 'societes.id')->orderBy('societes.statut', $_GET['order'])->where('contacts.etat', 1)->get();
$tri = 'client';
} elseif ($_GET['sort'] == 'created_at') {
$tri = 'ajout';
$contact = $contacts->with('societe')->where('etat', 1)->sortable()->get();
} elseif ($_GET['sort'] == 'updated_at') {
$tri = 'modif';
$contact = $contacts->with('societe')->where('etat', 1)->sortable()->get();
} elseif ($_GET['sort'] == 'nom_contact') {
$tri = 'alpha';
$contact = $contacts->with('societe')->where('etat', 1)->sortable()->get();
} elseif ($_GET['sort'] == 'societe_id') {
$contact = DB::table('contacts')->leftjoin('societes', 'contacts.societe_id', '=', 'societes.id')->orderBy('societes.nom_clt', $_GET['order'])->where('contacts.etat', 1)->get();
$tri = 'societe';
} elseif ($_GET['sort'] == 'ville_siege_clt') {
$contact = DB::table('contacts')->leftjoin('societes', 'contacts.societe_id', '=', 'societes.id')->orderBy('societes.ville_siege_clt', $_GET['order'])->where('contacts.etat', 1)->get();
$tri = 'ville';
} elseif ($_GET['sort'] == 'notes') {
$contact = $contacts->with('notes')->where('etat', 1)->orderBy('nom_contact', $_GET['sort'])->get();
$tri = 'notes';
}
} else {
$tri = 'alpha';
$contact = $contacts->with('societe')->where('etat', 1)->orderBy('nom_contact', 'asc')->get();
}
return view('contact.contact', compact('actif', 'contact', 'type', 'tri'));
}
示例3: DeleteCheckedDocs
public function DeleteCheckedDocs(Request $request)
{
$i = 1;
$data = $request->all();
if ($request->input('supp')) {
if ($data['type'] == 0 || $data['type'] == 3) {
foreach ($data as $key => $value) {
if (substr($key, 0, 1) == 'c') {
$profil = Societe::findOrFail($value);
$profil->update(['etat' => 0]);
}
}
} elseif ($data['type'] == 1) {
foreach ($data as $key => $value) {
if (substr($key, 0, 1) == 'c') {
$profil = Contact::findOrFail($value);
$profil->update(['etat' => 0]);
}
}
} elseif ($data['type'] == 2) {
foreach ($data as $key => $value) {
if (substr($key, 0, 1) == 'c') {
$profil = Groupe::findOrFail($value);
$profil->update(['etat' => 0]);
}
}
}
}
// Import de contacts
if ($request->input('export')) {
Excel::create('ExportContact', function ($excel) {
$excel->sheet('Sheetname', function ($sheet) {
$donnees = Input::all();
$j = 0;
if ($donnees['type'] == 0 || $donnees['type'] == 3) {
foreach ($donnees as $key => $value) {
if (substr($key, 0, 1) == 'c') {
$profil = Societe::findOrFail($value);
$export[$key] = $profil;
}
}
foreach ($export as $donnees) {
$extract[$j] = ['Nom de la société' => $donnees->nom_clt, 'Effectif' => $donnees->effectif_clt, 'Chiffre d\'affaire' => $donnees->ca_clt, 'N° TVA' => $donnees->num_tva_clt, 'URL' => $donnees->url_clt, 'Téléphone' => $donnees->tel_siege_clt, 'Fax' => $donnees->fax_siege_clt, 'E-mail' => $donnees->email_siege_clt, 'Pays' => $donnees->pays_clt, 'Ville' => $donnees->ville_siege_clt, 'Adresse' => $donnees->adresse_siege_clt, 'Commentaire' => $donnees->comment_clt];
$j++;
}
} elseif ($donnees['type'] == 1) {
foreach ($donnees as $key => $value) {
if (substr($key, 0, 1) == 'c') {
$profil = Contact::with(['societe' => function ($query) {
$query->with(['groupe'])->select('nom_clt', 'id', 'groupe_id');
}])->findOrFail($value);
$export[$key] = $profil;
}
}
foreach ($export as $donnees) {
$extract[$j] = ['Civilité' => $donnees->genre_contact, 'Nom' => $donnees->nom_contact, 'Prénom' => $donnees->prenoms_contact, 'Société' => isset($donnees->societe->nom_clt) ? $donnees->societe->nom_clt : NULL, 'Groupe' => isset($donnees->societe->groupe->nom_groupe) ? $donnees->societe->groupe->nom_groupe . ' ' . $donnees->societe->groupe->date_groupe : NULL, 'Fonction' => $donnees->fonction_contact, 'Service' => $donnees->service_contact, 'Description' => $donnees->description_contact, 'Téléphone' => $donnees->tel_contact, 'E-mail' => $donnees->email_contact, 'Adresse' => $donnees->adresse_contact];
$j++;
}
} elseif ($donnees['type'] == 2) {
foreach ($donnees as $key => $value) {
if (substr($key, 0, 1) == 'c') {
$profil = Groupe::findOrFail($value)->societe()->where('etat', 1)->get();
foreach ($profil as $pkey => $pvalue) {
$export[$key] = $pvalue;
}
}
}
var_dump($export);
dd();
foreach ($export as $donnees) {
$extract[$j] = ['Civilité' => $donnees->genre_contact, 'Nom' => $donnees->nom_contact, 'Prénom' => $donnees->prenoms_contact, 'Société' => isset($donnees->societe->nom_clt) ? $donnees->societe->nom_clt : NULL, 'Groupe' => isset($donnees->societe->groupe->nom_groupe) ? $donnees->societe->groupe->nom_groupe . ' ' . $donnees->societe->groupe->date_groupe : NULL, 'Fonction' => $donnees->fonction_contact, 'Service' => $donnees->service_contact, 'Description' => $donnees->description_contact, 'Téléphone' => $donnees->tel_contact, 'E-mail' => $donnees->email_contact, 'Adresse' => $donnees->adresse_contact];
$j++;
}
}
$sheet->fromArray($extract);
});
})->export('xls');
}
// Import des contacts à partir du Groupe CRM
if ($request->input('export')) {
Excel::create('ExportContact', function ($excel) {
$excel->sheet('Sheetname', function ($sheet) {
$donnees = Input::all();
$j = 0;
if ($donnees['type'] == 0) {
foreach ($donnees as $key => $value) {
if (substr($key, 0, 1) == 'c') {
$profil = Societe::findOrFail($value);
$export[$key] = $profil;
}
}
foreach ($export as $donnees) {
$extract[$j] = ['Nom de la société' => $donnees->nom_clt, 'Effectif' => $donnees->effectif_clt, 'Chiffre d\'affaire' => $donnees->ca_clt, 'N° TVA' => $donnees->num_tva_clt, 'URL' => $donnees->url_clt, 'Téléphone' => $donnees->tel_siege_clt, 'Fax' => $donnees->fax_siege_clt, 'E-mail' => $donnees->email_siege_clt, 'Pays' => $donnees->pays_clt, 'Ville' => $donnees->ville_siege_clt, 'Adresse' => $donnees->adresse_siege_clt, 'Commentaire' => $donnees->comment_clt];
$j++;
}
} else {
foreach ($donnees as $key => $value) {
if (substr($key, 0, 1) == 'c') {
$profil = Contact::with(['societe' => function ($query) {
$query->with(['groupe'])->select('nom_clt', 'id', 'groupe_id');
//.........这里部分代码省略.........
示例4: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
// Get all the files associated with the retrieved contact
$contacts = Contact::with('files')->get();
return $contacts;
}
示例5: function
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
use App\User;
Route::get('/', ['middleware' => 'auth', function () {
if (Entrust::hasRole('admin')) {
$users = \App\Role::where('name', '=', 'user')->firstOrFail()->users;
return View('admin/admin_home')->with('users', $users);
} elseif (Entrust::hasRole('user')) {
$current_user = Auth::user();
$contacts = \App\Contact::with('emails', 'phoneNumbers')->where('user_id', '=', $current_user->id)->get();
return View('contacts/user_home')->with('contacts', $contacts);
}
return view('welcome');
}]);
// Authentication routes...
Route::get('auth/login', 'Auth\\AuthController@getLogin');
Route::post('auth/login', 'Auth\\AuthController@postLogin');
Route::get('auth/logout', 'Auth\\AuthController@getLogout');
// Admin routes
Route::group(['middleware' => 'auth'], function () {
// only users with roles that have the 'edit-users' permission will be able to access any route within admin/post
Entrust::routeNeedsPermission('admin/*', 'edit-users', Redirect::to('errors/403'));
Route::get('admin/create_user', 'Admin\\AdminController@getCreateUser');
Route::post('admin/create_user', 'Admin\\AdminController@postCreateUser');
Route::get('admin/delete_user/{id}', 'Admin\\AdminController@getDeleteUser');