|
@@ -0,0 +1,575 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Http\Controllers;
|
|
|
+
|
|
|
+use App\DMCities;
|
|
|
+use App\Models\OrderActivities;
|
|
|
+use App\Models\Orders;
|
|
|
+use App\Models\Outlets;
|
|
|
+use App\Restaurants;
|
|
|
+use App\User;
|
|
|
+use App\RestoUsers;
|
|
|
+use App\SendEmail;
|
|
|
+use Carbon\Carbon;
|
|
|
+use Illuminate\Http\Request;
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
+use Illuminate\Support\Facades\Hash;
|
|
|
+use Illuminate\Support\Str;
|
|
|
+use Session;
|
|
|
+use Auth;
|
|
|
+use File;
|
|
|
+use Image;
|
|
|
+use Brian2694\Toastr\Facades\Toastr;
|
|
|
+use Illuminate\Support\Facades\Redis;
|
|
|
+use App\Helpers\CommonMethods;
|
|
|
+class HomeController extends Controller
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * Create a new controller instance.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function __construct()
|
|
|
+ {
|
|
|
+ // $this->middleware('auth');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function marketings(){
|
|
|
+
|
|
|
+ return view('marketing.marketings');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function change_lang($lang){
|
|
|
+ session(['app_lang' => $lang]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function reset_customer(){
|
|
|
+ return view('customers.customers');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getOrderActivities($id){
|
|
|
+ $status_array = ["Placed","Accepted","On_Road","Has_Delivered"];
|
|
|
+ $orderActivities = OrderActivities::where('order_id',$id)->get();
|
|
|
+
|
|
|
+ $new_array = [];
|
|
|
+ foreach($orderActivities as $status){
|
|
|
+ $new_array[$status->status] = array('id'=>$status->id,'description'=>$status->status.' found');
|
|
|
+ }
|
|
|
+ $final_array = [];
|
|
|
+ foreach($status_array as $status){
|
|
|
+ if(isset($new_array[$status])){
|
|
|
+ $final_array[$status] = $new_array[$status];
|
|
|
+ }else{
|
|
|
+ $final_array[$status] = array('id'=>0,'description'=>$status. ' not found in activities');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ dump($final_array);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getDashboardAnalytics(Request $request){
|
|
|
+
|
|
|
+ $s = $request->start_date;
|
|
|
+ $e = $request->end_date;
|
|
|
+
|
|
|
+ // $s = "2023-08-16";
|
|
|
+ // $e = "2023-09-14";
|
|
|
+ $start_date = Carbon::parse($s)->format('Y-m-d');
|
|
|
+ if($s==$e)
|
|
|
+ $start_date = Carbon::parse($s)->subDay()->format('Y-m-d');
|
|
|
+
|
|
|
+ $end_date = Carbon::parse($e)->format('Y-m-d');
|
|
|
+ $resto_id = CommonMethods::getRestuarantID();
|
|
|
+ $orders = Orders::whereNull('deleted_at')->where('resto_id',$resto_id)->where('status','Has_Delivered')->whereBetween('created_at',[$start_date,$end_date])->count();
|
|
|
+ // dd($orders);
|
|
|
+ $total_revenue = DB::table('tb_dm_orders')
|
|
|
+ ->select(DB::raw('(sum(total_price)) as total_price '))
|
|
|
+ ->where('resto_id' , $resto_id)
|
|
|
+ ->where('status','Has_Delivered')
|
|
|
+ ->whereBetween('created_at',[$start_date,$end_date])
|
|
|
+ ->whereNull('deleted_at')->first();
|
|
|
+
|
|
|
+ $total_price = isset($total_revenue)?$total_revenue->total_price:0;
|
|
|
+
|
|
|
+ $old_customer = \App\Models\Orders::select(\DB::raw('count(count(customer_id)) OVER() as customer_order'))->where('resto_id',$resto_id)->where('status','Has_Delivered')
|
|
|
+ ->whereBetween('created_at',[$start_date,$end_date])->groupBy('customer_id')->having(\DB::raw('count(customer_id)'),'>',1)->first();
|
|
|
+ $old_customer = isset($old_customer)?($old_customer->customer_order):0;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $new_customer = \App\Models\Orders::select(\DB::raw('count(customer_id) as customer_order'))->where('resto_id',$resto_id)->where('status','Has_Delivered')
|
|
|
+ ->whereBetween('created_at',[$start_date,$end_date])->groupBy('customer_id')->having(\DB::raw('count(customer_id)'),'=',1)->get()->toArray();
|
|
|
+ $new_customer = array_sum(array_column($new_customer, 'customer_order'));
|
|
|
+
|
|
|
+ $old_orders = \App\Models\Orders::select(\DB::raw('count(id) as customer_order'))->where('resto_id',$resto_id)->where('status','Has_Delivered')
|
|
|
+ ->whereBetween('created_at',[$start_date,$end_date])->groupBy('customer_id')->having(\DB::raw('count(id)'),'>',1)->get()->toArray();
|
|
|
+ $old_orders = array_sum(array_column($old_orders, 'customer_order'));
|
|
|
+
|
|
|
+ $new_order = \App\Models\Orders::select(\DB::raw('count(id) as customer_order'))->where('resto_id',$resto_id)->where('status','Has_Delivered')
|
|
|
+ ->whereBetween('created_at',[$start_date,$end_date])->groupBy('customer_id')->having(\DB::raw('count(id)'),'=',1)->get()->toArray();
|
|
|
+ //dd($new_order);
|
|
|
+
|
|
|
+ $new_order = array_sum(array_column($new_order, 'customer_order'));
|
|
|
+
|
|
|
+// $order_status_customers = \App\Models\Orders::select(\DB::raw('count(customer_id) as customer_order'))
|
|
|
+// ->whereBetween('created_at',[$start_date,$end_date])
|
|
|
+// ->where('customer_order' ,'>',1)
|
|
|
+// ->where('resto_id',$resto_id)->where('status','Has_Delivered')->groupBy('customer_id')->get()->take(2);
|
|
|
+
|
|
|
+
|
|
|
+ $average_new_order = \App\Models\Orders::select(\DB::raw('sum(sum(total_price)) OVER() as total_price'))->where('resto_id',$resto_id)->where('status','Has_Delivered')
|
|
|
+ ->whereBetween('created_at',[$start_date,$end_date])->groupBy('customer_id')->having(\DB::raw('count(id)'),'=',1)->first();
|
|
|
+
|
|
|
+ // dd($average_new_order);
|
|
|
+
|
|
|
+ $average_new_order = isset($average_new_order)?$average_new_order->total_price:0;
|
|
|
+
|
|
|
+
|
|
|
+ $average_old_order = \App\Models\Orders::select(\DB::raw('sum(sum(total_price)) OVER() as total_price'))->where('resto_id',$resto_id)->where('status','Has_Delivered')
|
|
|
+ ->whereBetween('created_at',[$start_date,$end_date])->groupBy('customer_id')->having(\DB::raw('count(id)'),'>',1)->first();
|
|
|
+
|
|
|
+ $average_old_order = isset($average_old_order)?$average_old_order->total_price:0;
|
|
|
+
|
|
|
+ $campaign_data = \App\Models\Orders::select(\DB::raw('count(campaign_type) as total_campaign'),'campaign_type')->where('resto_id',$resto_id)->where('status','Has_Delivered')
|
|
|
+ ->whereBetween('created_at',[$start_date,$end_date])->groupBy('campaign_type')->having('total_campaign','>',0)->get();
|
|
|
+
|
|
|
+ $outlet_data = \App\Models\Orders::with('outlet')->select(\DB::raw('count(outlet_id) as total_outlet_orders'),'outlet_id')->where('resto_id',$resto_id)->where('status','Has_Delivered')
|
|
|
+ ->whereBetween('created_at',[$start_date,$end_date])->groupBy('outlet_id')->having('total_outlet_orders','>',0)->get();
|
|
|
+
|
|
|
+ $outlet_data_array = [];
|
|
|
+
|
|
|
+ if($outlet_data){
|
|
|
+ foreach($outlet_data as $d){
|
|
|
+ $outlet_data_array[$d->outlet_id] = array('outlet_name'=>$d->outlet->name,'orders'=>$d->total_outlet_orders);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $outlets = Outlets::where('resto_id',$resto_id)->whereNull('deleted_at')->get();
|
|
|
+ $outlets_array = [];
|
|
|
+ if($outlets){
|
|
|
+ foreach($outlets as $outlet){
|
|
|
+ if(isset($outlet_data_array[$outlet->id]))
|
|
|
+ $outlets_array[] = array('name'=>$outlet->name,'orders'=>$outlet_data_array[$outlet->id]['orders']);
|
|
|
+ else
|
|
|
+ $outlets_array[] = array('name'=>$outlet->name,'orders'=>0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // dd($average_old_order,$average_new_order);
|
|
|
+
|
|
|
+
|
|
|
+ $total_customers = $old_customer + $new_customer;
|
|
|
+ $total_orders = $old_orders + $new_order;
|
|
|
+ $dasboard_data = array(
|
|
|
+ 'total_orders'=>number_format($orders),
|
|
|
+ 'total_sale'=>number_format($total_price),
|
|
|
+ 'order_rating'=>'N/A',
|
|
|
+ 'average_basket_value'=>$orders > 0 && $total_price > 0?number_format( round($total_price / $orders,2)):"N/A",
|
|
|
+ 'customers'=>array(
|
|
|
+ 'new_customer'=>array('value'=>$new_customer,'percentage'=>(round($new_customer / ($total_customers?$total_customers:1),2)*100).'%'),
|
|
|
+ 'old_customer'=>array('value'=>$old_customer,'percentage'=>(round($old_customer / ($total_customers?$total_customers:1),2)*100).'%'),
|
|
|
+ ),
|
|
|
+ 'orders'=>array(
|
|
|
+ 'new_orders'=>array('value'=>$new_order,'percentage'=>number_format(round($new_order / ($total_orders > 0?$total_orders:1),2)*100).'%'),
|
|
|
+ 'old_orders'=>array('value'=>$old_orders,'percentage'=>number_format(round($old_orders / ($total_orders > 0?$total_orders:1),2)*100).'%'),
|
|
|
+ ),
|
|
|
+ 'average_basket'=>array(
|
|
|
+ 'new'=>$new_order > 0?number_format(round($average_new_order/$new_order,2)):0,
|
|
|
+
|
|
|
+ 'returning'=>$old_orders > 0?number_format(round($average_old_order/$old_orders,2)):0,
|
|
|
+ 'total_averge_basket'=>round(($new_order > 0?($average_new_order/$new_order):0) + ($old_orders > 0?$average_old_order/$old_orders:0),2),
|
|
|
+ ),
|
|
|
+
|
|
|
+ 'total_basket_sale'=>array(
|
|
|
+ 'new'=>$new_order > 0?number_format(round($average_new_order,2)):0,
|
|
|
+ 'returning'=>$old_orders > 0?number_format(round($average_old_order,2)):0,
|
|
|
+ 'total_sale'=> round(($new_order > 0?$average_new_order:0)+($old_orders > 0?$average_old_order:0),2)
|
|
|
+ ),
|
|
|
+ 'order_by_source'=>$campaign_data,
|
|
|
+ 'order_by_outlet'=>$outlets_array
|
|
|
+
|
|
|
+ );
|
|
|
+
|
|
|
+ return response()->json($dasboard_data,200);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public function reset_phone_customer(Request $request){
|
|
|
+ $user = User::where('email',$request->mobile_number)->first();
|
|
|
+ if(isset($user)){
|
|
|
+ $existing_email = $user->email;
|
|
|
+ $existing_email = $existing_email.'-reset-at-'.date('y-m-d H:i:s');
|
|
|
+ $user->email = $existing_email;
|
|
|
+ $user->save();
|
|
|
+ echo json_encode(array('type'=>'success','message'=>$request->mobile_number. ' is reset.'));
|
|
|
+ }else{
|
|
|
+ echo json_encode(array('type'=>'error','message'=>$request->mobile_number. ' not found in db, use correct number with country code'));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function reset_update_password(Request $request){
|
|
|
+ $user_id = $request->user_id;
|
|
|
+
|
|
|
+ $user = User::find($user_id);
|
|
|
+
|
|
|
+ $username = $user->username;
|
|
|
+
|
|
|
+ $password = $request->password;
|
|
|
+
|
|
|
+ $user->password = Hash::make($password);
|
|
|
+ $user->is_reset_password_sent = "Changed";
|
|
|
+ $result = $user->save();
|
|
|
+
|
|
|
+ if($result){
|
|
|
+ Auth::loginUsingId($user_id);
|
|
|
+ return response()->json(array('type'=>'success','message'=>'Password reset successfully.'));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function reset_password(Request $request){
|
|
|
+ $user_id = $request->get('u');
|
|
|
+ $user = User::where('id',$user_id)->where('is_reset_password_sent','Yes')->first();;
|
|
|
+
|
|
|
+ return view('reset-password',['user'=>$user]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function send_reset_link(Request $request){
|
|
|
+ $email = $request->email;
|
|
|
+
|
|
|
+ $user_id = "";
|
|
|
+
|
|
|
+ $user = User::where('username',$email)->first();
|
|
|
+
|
|
|
+ if(isset($user))
|
|
|
+ $user_id = $user->id;
|
|
|
+
|
|
|
+ if(!isset($user)){
|
|
|
+ $user = RestoUsers::whereNull('deleted_at')->where('email',$email)->first();
|
|
|
+
|
|
|
+ $user_id = isset($user->user_id)?$user->user_id:"";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if(!isset($user) && empty($user_id))
|
|
|
+ return response()->json(['type'=>'error','message'=>'No user found against this <strong>'.$request->email.'</strong>']);
|
|
|
+
|
|
|
+ $u = User::where('id',$user_id)->update(['is_reset_password_sent'=>'Yes']);
|
|
|
+
|
|
|
+ $param = array(
|
|
|
+ 'email'=>$request->email,
|
|
|
+ 'name' => $user->first_name,
|
|
|
+ 'link'=> env('APP_URL').'reset/my/password?q='.md5(time()).'&u='.$user->user_id.'&action=reset'
|
|
|
+ );
|
|
|
+
|
|
|
+ SendEmail::SendRestPasswordLink($param);
|
|
|
+
|
|
|
+ return response()->json(['type'=>'success','message'=>'Reset link sent to <strong>'.$request->email.'</strong>']);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function send_mail(){
|
|
|
+ $logo = 'https://meemappaws.imgix.net/meemcdn/31-titanium-store/titanium-store-logo-1669151471?fm=webp&h=500&w=500&trim=color&q=100&fit=center&crop=center';
|
|
|
+
|
|
|
+ $imageData = base64_encode(file_get_contents($logo));
|
|
|
+ $logo = 'data:image/png;base64,'.$imageData;
|
|
|
+ $param = array(
|
|
|
+ 'email'=>$_GET['email'],
|
|
|
+
|
|
|
+ 'shop_name' => 'Titanium Store',
|
|
|
+ 'order_message' => 'You have New order placed OrderID: 217 , kindly login to https://admin.meemorder.io to serve customer.',
|
|
|
+ 'logo' => $logo
|
|
|
+
|
|
|
+ );
|
|
|
+
|
|
|
+
|
|
|
+ SendEmail::sendOrderNotification($param);
|
|
|
+
|
|
|
+ exit;
|
|
|
+ $param = array(
|
|
|
+ 'email'=>$_GET['email'],
|
|
|
+ 'name' => 'Mujtaba Ahmad',
|
|
|
+ 'shop_name' => 'NB Flowers',
|
|
|
+ 'role' => 'Manager',
|
|
|
+ 'access_level' => 'selected-outlets',
|
|
|
+ 'selected_outlets' => 'Outlet1, Outlet2',
|
|
|
+ //'link' => 'https://dashboard.chatfood.io/invite/36eaa3c8403efe29d775db4423a62bb0?utm_medium=email&utm_source=mailgun&utm_campaign=user_invitation',
|
|
|
+ 'link' => '#'
|
|
|
+ );
|
|
|
+
|
|
|
+ SendEmail::SendInvitationLink($param);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function test_redis(){
|
|
|
+ Redis::set("user:mujtaba","It is testing code");
|
|
|
+
|
|
|
+ dd(Redis::get('user:mujtaba'));
|
|
|
+ }
|
|
|
+
|
|
|
+ public function create_link(Request $request){
|
|
|
+ $campaign_name = $request->campaign_name;
|
|
|
+ $campaign_date = $request->campaign_date;
|
|
|
+ $campaign_type = $request->campaign_type;
|
|
|
+ $site_url = $request->site_url;
|
|
|
+
|
|
|
+ $link = '?a='.$campaign_type.'&c='.Str::slug($campaign_name).'&cd='.$campaign_date;
|
|
|
+
|
|
|
+ return $site_url.($link);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public function make_slug(){
|
|
|
+ $resto = Restaurants::all();
|
|
|
+
|
|
|
+ foreach($resto as $r){
|
|
|
+ $rr = Restaurants::find($r->id);
|
|
|
+
|
|
|
+ $rr->resto_unique_name = Str::slug($r->name);
|
|
|
+ $rr->save();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Show the application dashboard.
|
|
|
+ *
|
|
|
+ * @return \Illuminate\Contracts\Support\Renderable
|
|
|
+ */
|
|
|
+ public function index()
|
|
|
+ {
|
|
|
+ return view('auth.login');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function dashboard(){
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if(Auth::user()->role=="administrator")
|
|
|
+ return view('dashboards.admin_dashboard');
|
|
|
+ return view('dashboards.resto_dashboard');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getLogout()
|
|
|
+ {
|
|
|
+ Session::flush();
|
|
|
+ Auth::logout();
|
|
|
+
|
|
|
+ return redirect('/');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function change_password(){
|
|
|
+ return view('password');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function update_password(Request $request){
|
|
|
+ $old_password = $request->old_password;
|
|
|
+
|
|
|
+ $new_password = $request->password;
|
|
|
+ $confirm_password = $request->confirm_password;
|
|
|
+ $user = Auth::user();
|
|
|
+ if ($user && Hash::check($old_password, $user->password)) {
|
|
|
+
|
|
|
+ if($new_password==$confirm_password){
|
|
|
+
|
|
|
+ $u = User::find($user->id);
|
|
|
+ $u->password = Hash::make($new_password);
|
|
|
+ $u->save();
|
|
|
+
|
|
|
+ echo json_encode(array('type'=>'success','message'=>'Password changed successfully.'));
|
|
|
+
|
|
|
+
|
|
|
+ }else{
|
|
|
+ echo json_encode(array('type'=>'error','message'=>'new password and confirm password are not matched.'));
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{
|
|
|
+ echo json_encode(array('type'=>'error','message'=>'Old password is incorrect, enter correct password.'));
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function download_image(Request $request){
|
|
|
+ $data = $request->data;
|
|
|
+ $resto = $request->resto;
|
|
|
+
|
|
|
+ $data = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $data));
|
|
|
+ file_put_contents(public_path('/uploads/qrcode/qrcode.png'), $data);
|
|
|
+
|
|
|
+ $this->image_recreate(public_path('/uploads/qrcode/qrcode.png'),public_path('/uploads/qrcode/'.$resto.'-qrcode.png'));
|
|
|
+
|
|
|
+ echo env('APP_PUBLIC_URL').'uploads/qrcode/'.$resto.'-qrcode.png';
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function image_recreate($sourceFile,$destinationFile){
|
|
|
+ $orig_filename = $sourceFile;
|
|
|
+ $new_filename = $orig_filename;
|
|
|
+
|
|
|
+ list($orig_w, $orig_h) = getimagesize($orig_filename);
|
|
|
+
|
|
|
+ $orig_img = imagecreatefromstring(file_get_contents($orig_filename));
|
|
|
+
|
|
|
+ $output_w = 2200;
|
|
|
+ $output_h = 2200;
|
|
|
+
|
|
|
+// determine scale based on the longest edge
|
|
|
+ if ($orig_h > $orig_w) {
|
|
|
+ $scale = $output_h/$orig_h;
|
|
|
+ } else {
|
|
|
+ $scale = $output_w/$orig_w;
|
|
|
+ }
|
|
|
+
|
|
|
+ $scale = $scale-0.1;
|
|
|
+
|
|
|
+ // calc new image dimensions
|
|
|
+ $new_w = ($orig_w * $scale);
|
|
|
+ $new_h = ($orig_h * $scale);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// determine offset coords so that new image is centered
|
|
|
+ $offest_x = (($output_w - $new_w) / 2);
|
|
|
+ $offest_y = (($output_h - $new_h) / 2);
|
|
|
+
|
|
|
+ // create new image and fill with background colour
|
|
|
+ $new_img = imagecreatetruecolor($output_w, $output_h);
|
|
|
+ $bgcolor = imagecolorallocate($new_img, 255, 255, 255); // red
|
|
|
+ imagefill($new_img, 0, 0, $bgcolor); // fill background colour
|
|
|
+
|
|
|
+ // copy and resize original image into center of new image
|
|
|
+ imagecopyresampled($new_img, $orig_img, $offest_x, $offest_y, 0, 0, $new_w, $new_h, $orig_w, $orig_h);
|
|
|
+
|
|
|
+ //save it
|
|
|
+ imagejpeg($new_img, $destinationFile, 80);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public function resizeMainRecipeImages(){
|
|
|
+ $path = public_path('uploads/main_image');
|
|
|
+
|
|
|
+ ini_set('max_execution_time', '300');
|
|
|
+
|
|
|
+ $files = File::allfiles($path);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ foreach($files as $file){
|
|
|
+
|
|
|
+ $pth = ($file->getRealPath());
|
|
|
+ $file_name = $file->getFileName();
|
|
|
+ echo "Main Image: ".$file_name."<br />";
|
|
|
+ $destinationPath = public_path('/uploads/main_image/');
|
|
|
+ if($file->getExtension()!="jfif") {
|
|
|
+ $img = Image::make($destinationPath . '/' . $file_name)->resize(85, null, function ($constraint) {
|
|
|
+ $constraint->aspectRatio();
|
|
|
+ });
|
|
|
+
|
|
|
+ $img->save($destinationPath . '/thumbnails/' . $file_name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public function resizeLogo(){
|
|
|
+ $path = public_path('uploads/logo');
|
|
|
+
|
|
|
+ ini_set('max_execution_time', '300');
|
|
|
+
|
|
|
+ $files = File::allfiles($path);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ foreach($files as $file){
|
|
|
+
|
|
|
+ $pth = ($file->getRealPath());
|
|
|
+ $file_name = $file->getFileName();
|
|
|
+ echo "Main Image: ".$file_name."<br />";
|
|
|
+ $destinationPath = public_path('/uploads/logo/');
|
|
|
+ if($file->getExtension()!="jfif") {
|
|
|
+ $img = Image::make($destinationPath . '/' . $file_name)->resize(50, null, function ($constraint) {
|
|
|
+ $constraint->aspectRatio();
|
|
|
+ });
|
|
|
+
|
|
|
+ $img->save($destinationPath . '/thumbnails/' . $file_name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function resizeGalleryRecipeImages(){
|
|
|
+ $path = public_path('uploads/resto-gallery');
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $files = File::allfiles($path);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ foreach($files as $file){
|
|
|
+
|
|
|
+ $pth = ($file->getRealPath());
|
|
|
+ $file_name = $file->getFileName();
|
|
|
+ echo "Gallery: ".$file_name."<br />";
|
|
|
+ $destinationPath = public_path('/uploads/resto-gallery/');
|
|
|
+ if($file->getExtension()!="jfif"){
|
|
|
+ $img = Image::make($destinationPath . '/' . $file_name)->resize(800, null, function ($constraint) {
|
|
|
+ $constraint->aspectRatio();
|
|
|
+ });
|
|
|
+
|
|
|
+ $img->save($destinationPath . '/thumbnails/' . $file_name);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function resizeGalleryRecipeImagesToGallery(){
|
|
|
+ $path = public_path('uploads/resto-gallery');
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $files = File::allfiles($path);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ foreach($files as $file){
|
|
|
+
|
|
|
+ $pth = ($file->getRealPath());
|
|
|
+ $file_name = $file->getFileName();
|
|
|
+ echo "Gallery: ".$file_name."<br />";
|
|
|
+ $destinationPath = public_path('/uploads/resto-gallery/');
|
|
|
+ if($file->getExtension()!="jfif"){
|
|
|
+ $img = Image::make($destinationPath . '/' . $file_name)->resize(800, null, function ($constraint) {
|
|
|
+ $constraint->aspectRatio();
|
|
|
+ });
|
|
|
+
|
|
|
+ $img->save($destinationPath . '/gallery-resized/' . $file_name);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function load_json(){
|
|
|
+ $jsonString = file_get_contents("https://api.chatfood.io/api/v1/businesses/ceeba7a3-5dd4-48a7-9a07-96111efab2e4/areas");
|
|
|
+
|
|
|
+ $data = json_decode($jsonString, true);
|
|
|
+ // dd($data);
|
|
|
+
|
|
|
+ foreach($data as $city){
|
|
|
+ foreach($city as $cc){
|
|
|
+ // dump($cc);
|
|
|
+ $c = new DMCities();
|
|
|
+
|
|
|
+ $c->city_name = $cc['name'];
|
|
|
+ $c->city_unique_id = $cc['id'];
|
|
|
+
|
|
|
+ $c->save();
|
|
|
+ }
|
|
|
+ /* */
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|