本文整理汇总了PHP中app\models\Customer::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::orderBy方法的具体用法?PHP Customer::orderBy怎么用?PHP Customer::orderBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Customer
的用法示例。
在下文中一共展示了Customer::orderBy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index(){
$data = [
'auth'=>false,
'recentAdded'=>Customer::orderBy('created_at', 'desc')->take(5)->get()
];
return view('home', $data);
}
示例2: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$customers = Customer::orderBy('CUSTCODE', 'ASC')->paginate(15);
return view('frontend.customers.index', compact('customers'));
}
示例3: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
$this->validate($request, ['area_id' => 'required', 'enrollment_id' => 'required', 'distributor_id' => 'required', 'client_id' => 'required', 'channel_id' => 'required', 'customer_id' => 'required', 'region_id' => 'required', 'agency_id' => 'required', 'store_name' => 'required', 'store_id' => 'required']);
// $diff_items = array_diff( $channel_items, $store_items );
// $same_items = array_intersect( $channel_items, $store_items );
// $add_store_items = ChannelItem::select('item_id',
// 'item_type_id',
// 'ig',
// 'fso_multiplier',
// 'min_stock',
// 'ig_updated',
// 'osa_tagged',
// 'npi_tagged' )
// ->whereIn('item_id',$diff_items)
// ->where('channel_id',$request->channel_id)
// ->get();
// foreach ($add_store_items as &$data) {
// $data->store_id = $id;
// }
// $delete = StoreItem::where('store_id',$id)->whereNotIn('item_id',$same_items)->delete();
// foreach ($add_store_items as $data) {
// $check[] = StoreItem::firstOrCreate([
// 'store_id' => $data->store_id,
// 'item_id' => $data->item_id,
// 'item_type_id' => $data->item_type_id,
// 'ig' => $data->ig,
// 'fso_multiplier' => $data->fso_multiplier,
// 'min_stock' => $data->min_stock,
// 'ig_updated' => $data->ig_updated,
// 'osa_tagged' => $data->npi_tagged ]);
// }
$store = Store::findOrFail($id);
//for mkl
$mkl_store_items = StoreItem::where('store_id', $id)->where('item_type_id', 1)->get()->pluck('item_id')->toArray();
//get all the item from store mkl
$mkl_channel_items = ChannelItem::where('channel_id', $request->channel_id)->where('item_type_id', 1)->get()->pluck('item_id')->toArray();
//for assortment
$assortment_store_items = StoreItem::where('store_id', $id)->where('item_type_id', 2)->get()->pluck('item_id')->toArray();
//get all the item from store assortment
$assortment_channel_items = ChannelItem::where('channel_id', $request->channel_id)->where('item_type_id', 2)->get()->pluck('item_id')->toArray();
//for mkl
foreach ($mkl_store_items as $value) {
if (!in_array($value, $mkl_channel_items)) {
$delete = StoreItem::where('store_id', $id)->where('item_type_id', 1)->where('item_id', $value)->delete();
}
}
$mkl_remaining_items = StoreItem::where('store_id', $id)->where('item_type_id', 1)->get()->pluck('item_id')->toArray();
foreach ($mkl_channel_items as $value) {
if (!in_array($value, $mkl_remaining_items)) {
$data = ChannelItem::where('item_id', $value)->where('channel_id', $request->channel_id)->where('item_type_id', 1)->first();
StoreItem::firstOrCreate(['store_id' => $id, 'item_id' => $data->item_id, 'item_type_id' => $data->item_type_id, 'ig' => $data->ig, 'fso_multiplier' => $data->fso_multiplier, 'min_stock' => $data->min_stock, 'ig_updated' => $data->ig_updated, 'osa_tagged' => $data->npi_tagged]);
}
}
//for assortment
foreach ($assortment_store_items as $value) {
if (!in_array($value, $assortment_channel_items)) {
$delete = StoreItem::where('store_id', $id)->where('item_type_id', 2)->where('item_id', $value)->delete();
}
}
$assortment_remaining_items = StoreItem::where('store_id', $id)->where('item_type_id', 2)->get()->pluck('item_id')->toArray();
foreach ($assortment_channel_items as $value) {
if (!in_array($value, $assortment_remaining_items)) {
$data = ChannelItem::where('item_id', $value)->where('channel_id', $request->channel_id)->where('item_type_id', 2)->first();
$w_mkl = StoreItem::where('store_id', $id)->where('item_id', $value)->get();
if (count($w_mkl) == 0) {
StoreItem::firstOrCreate(['store_id' => $id, 'item_id' => $data->item_id, 'item_type_id' => $data->item_type_id, 'ig' => $data->ig, 'fso_multiplier' => $data->fso_multiplier, 'min_stock' => $data->min_stock, 'ig_updated' => $data->ig_updated, 'osa_tagged' => $data->npi_tagged]);
}
}
}
//end
$store->area_id = $request->area_id;
$store->enrollment_id = $request->enrollment_id;
$store->distributor_id = $request->distributor_id;
$store->client_id = $request->client_id;
$store->channel_id = $request->channel_id;
$store->customer_id = $request->customer_id;
$store->region_id = $request->region_id;
$store->agency_id = $request->agency_id;
$store->store_name = $request->store_name;
$store->storeid = $request->store_id;
$store->store_code = $request->store_code;
$store->store_code_psup = $request->store_code_psup;
$store->active = $request->status;
$store->update();
\DB::table('store_users')->where('user_id', $request->userid)->where('store_id', $id)->update(['user_id' => $request->user_id]);
$store = Store::findOrFail($id);
$area = Area::orderBy('area', 'ASC')->lists('area', 'id');
$enrollment = Enrollment::orderBy('enrollment', 'ASC')->lists('enrollment', 'id');
$distributor = Distributor::orderBy('distributor', 'ASC')->lists('distributor', 'id');
$client = Client::orderBy('client_name', 'ASC')->lists('client_name', 'id');
$channel = channel::orderBY('channel_desc', 'ASC')->lists('channel_desc', 'id');
$customer = Customer::orderBy('customer_name', 'ASC')->lists('customer_name', 'id');
//.........这里部分代码省略.........
示例4: edit
public function edit($id)
{
if (!$this->hasPermission($this->menuPermissionName)) {
return view($this->viewPermissiondeniedName);
}
$model = CarPreemption::find($id);
$carPayment = CarPayment::where('carpreemptionid', $id)->first();
if (!Auth::user()->isadmin && $carPayment != null && $carPayment->deliverycarbookno != null && $carPayment->deliverycarbookno != '') {
return "ไม่สามารถแก้ไขข้อมูลการจองได้ เนื่องจากมีการส่งรถแล้ว!!";
}
$bookingcustomer = Customer::find($model->bookingcustomerid);
$model->bookingcustomername = $bookingcustomer->title . ' ' . $bookingcustomer->firstname . ' ' . $bookingcustomer->lastname;
$model->provincebranchid = $bookingcustomer->provinceid;
$model->bookingcustomeraddress = $bookingcustomer->address;
$model->bookingcustomerprovinceid = $bookingcustomer->addprovinceid;
$model->bookingcustomeramphurid = $bookingcustomer->amphurid;
$model->bookingcustomerdistrictid = $bookingcustomer->districtid;
$model->bookingcustomerzipcode = $bookingcustomer->zipcode;
$model->bookingcustomerphone1 = $bookingcustomer->phone1;
$model->bookingcustomerphone2 = $bookingcustomer->phone2;
$model->bookingcustomeroccupationid = $bookingcustomer->occupationid;
if ($bookingcustomer->birthdate != null && $bookingcustomer->birthdate != '') {
$model->bookingcustomerbirthdate = date('d-m-Y', strtotime($bookingcustomer->birthdate));
}
if ($model->bookingcustomerid != $model->buyercustomerid) {
$model->buyertype = 1;
$buyercustomer = Customer::find($model->buyercustomerid);
$model->buyercustomeraddress = $buyercustomer->address;
$model->buyercustomerprovinceid = $buyercustomer->addprovinceid;
$model->buyercustomeramphurid = $buyercustomer->amphurid;
$model->buyercustomerdistrictid = $buyercustomer->districtid;
$model->buyercustomerzipcode = $buyercustomer->zipcode;
$model->buyercustomerphone1 = $buyercustomer->phone1;
$model->buyercustomerphone2 = $buyercustomer->phone2;
$model->buyercustomeroccupationid = $buyercustomer->occupationid;
if ($buyercustomer->birthdate != null && $buyercustomer->birthdate != '') {
$model->buyercustomerbirthdate = date('d-m-Y', strtotime($buyercustomer->birthdate));
}
} else {
$model->buyertype = 0;
}
$provincebranchs = Province::whereHas('branchs', function ($q) {
$q->where('isheadquarter', true);
})->orderBy('name', 'asc')->get(['id', 'name']);
$provincebranchselectlist = array();
foreach ($provincebranchs as $item) {
$provincebranchselectlist[$item->id] = $item->name;
}
if (Auth::user()->isadmin) {
$customers = Customer::orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'title', 'firstname', 'lastname']);
} else {
$customers = Customer::where('provinceid', Auth::user()->provinceid)->orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'title', 'firstname', 'lastname']);
}
$customerselectlist = array();
$customerselectlist[null] = 'เลือกชื่อลูกค้า';
foreach ($customers as $item) {
$customerselectlist[$item->id] = $item->title . ' ' . $item->firstname . ' ' . $item->lastname;
}
$provinces = Province::orderBy('name', 'asc')->get(['id', 'name']);
$provinceselectlist = array();
$provinceselectlist[null] = 'เลือกจังหวัด';
foreach ($provinces as $item) {
$provinceselectlist[$item->id] = $item->name;
}
$bookingcustomeramphurs = Amphur::where('provinceid', $model->bookingcustomerprovinceid)->orderBy('name', 'asc')->get(['id', 'name']);
$bookingcustomeramphurselectlist = array();
$bookingcustomeramphurselectlist[null] = 'เลือกเขต/อำเภอ';
foreach ($bookingcustomeramphurs as $item) {
$bookingcustomeramphurselectlist[$item->id] = $item->name;
}
$buyercustomeramphurselectlist = array();
if ($model->bookingcustomerid != $model->buyercustomerid) {
$buyercustomeramphurs = Amphur::where('provinceid', $model->buyercustomerprovinceid)->orderBy('name', 'asc')->get(['id', 'name']);
$buyercustomeramphurselectlist[null] = 'เลือกเขต/อำเภอ';
foreach ($buyercustomeramphurs as $item) {
$buyercustomeramphurselectlist[$item->id] = $item->name;
}
}
$bookingcustomerdistricts = District::where('amphurid', $model->bookingcustomeramphurid)->orderBy('name', 'asc')->get(['id', 'name']);
$bookingcustomerdistrictselectlist = array();
$bookingcustomerdistrictselectlist[null] = 'เลือกแขวง/ตำบล';
foreach ($bookingcustomerdistricts as $item) {
$bookingcustomerdistrictselectlist[$item->id] = $item->name;
}
$buyercustomerdistrictselectlist = array();
if ($model->bookingcustomerid != $model->buyercustomerid) {
$buyercustomerdistricts = District::where('amphurid', $model->buyercustomeramphurid)->orderBy('name', 'asc')->get(['id', 'name']);
$buyercustomerdistrictselectlist[null] = 'เลือกแขวง/ตำบล';
foreach ($buyercustomerdistricts as $item) {
$buyercustomerdistrictselectlist[$item->id] = $item->name;
}
}
$occupations = Occupation::orderBy('name', 'asc')->get(['id', 'name']);
$occupationselectlist = array();
$occupationselectlist[null] = 'เลือกอาชีพ';
foreach ($occupations as $item) {
$occupationselectlist[$item->id] = $item->name;
}
$carmodels = CarModel::whereHas("carbrand", function ($q) {
$q->where('ismain', true);
//.........这里部分代码省略.........