Aronaman

Aronaman

Member Since 11 Months Ago

Experience Points
4,500
Total
Experience

500 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
3
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 1
4,500 XP
Feb
21
1 day ago
Activity icon

Replied to Collection Pass Blade

@talinon yea..but pluck and sum and implode method is not working in blade. I try to use it in view composer, but it's for static page url....

Feb
20
2 days ago
Activity icon

Replied to Collection Pass Blade

   return view('Local.checkBalance.index', compact('groups','payed','funded'))
                         ->with('i');

i pass it my question is how can do query in blade.

it is possible in blade like this

@foreach ($groups as $key => $group)

$BookingIds=$group->pluck('id');
$first=$group->first();

b/c pluck and where are collection on controller not in blade ?/ there is any way??

Activity icon

Started a new Conversation Collection Pass Blade

Hyy guys Any trick or tip This my code

      $lists=Booking::with('localreservation')->where('approve_date',null)
                                       ->where('booked_by',$auth )
                                       ->whereDate('updated_at',$toDay)
                                       
                                       ->get();
      $groups=$lists->groupBy('validation_code')->toArray();
 dd($groups

output

array:3 [▼
  "vN9-2020-02-20" => array:1 [▼
    0 => array:31 [▼
      "id" => 7
      "bookable_type" => "App\Room"
      "bookable_id" => 2
      "local_reservation_id" => 46
      "name" => null
      "email" => null
      "booked_by" => "37"
      "user_id" => null
      "no_date" => 1
      "quantity" => 0
      "check_in" => "2020-02-27 00:00:00"
      "check_out" => "2020-02-28 00:00:00"
      "discount" => "0.05"
      …..
    ]
  ]
  "azZ-2020-02-20" => array:1 [▶]
  "KrB-2020-02-20" => array:3 [▶]

What I am try to do is for each blade

<table id="check_balance" class="display nowrap" style="width:100%">
  
  <thead>

   <tr>

     <th>No</th>

     <th>Date</th>

     <th>Name</th>
   
     <th>Phone No</th>

     <th>Types</th>

     <th>Booked By</th>

     <th>User Account</th>

      <th>Payed Amount</th>

      <th>Refund Amount</th>

     <th>Net</th>

    <th width="280px">Action</th>

    <!--  <th width="280px">Action</th> -->

   </tr>
</thead>

  
 <tbody>
 @foreach ($groups as $key => $group)

$BookingIds=$group->pluck('id');
$first=$group->first();
$types=$group->pluck('bookable');
<!-- ->flatten()->pluck('slug') -->
$implodeTypes=$types->implode('slug', ', ');

$payedAmount=$group->pluck('pay')->sum();
$refundAmount=$group->pluck('fund')->sum();
    <tr>
      <td>{{ ++$i }}</td>
      <td>{{$first->updated_at}}</td>


      <td>{{$first->localreservation->full_name}}</td>

      <td>{{$first->localreservation->phone_no}}</td>

      <td>{{$implodeTypes}}</td>
      <td>{{$first->booked_by}}</td>
      <td>{{$first->localreservation->localUserBankAccount}}</td>
      <td>{{$payedAmount}}</td>
      <td>{{$refundAmount}}</td>
      
      <td>{{$payedAmount-$refundAmount}}</td>

      <td>

         <a class="btn btn-primary" href="{{ route('local.approve',$BookingIds) }}">Approve</a>

      </td>
      
    </tr>
     @endforeach
  </tbody>

The problem is eloquent and collects query not used in blade, any suggestion, please!!

Activity icon

Replied to Pass Data In Json

@sergiu17, thanks for a fast reply !! is there is any simple method

in this method working fine, but i need to pass quantity and use

data:form_data,

but is change the json to string

 data:{
 quantity:quantity,
    form_data 
}
Activity icon

Started a new Conversation Pass Data In Json

how to change string to json /object

data:{
    quantity:quantity,
    form_data                                     
  }, // out put ---> form_data:"name=&type_of_organization=&city_id=&type=Room&start_price=300+ETB

to

// output --->   name: null, type_of_organization: null, city_id: "68", type: "Room", 
Feb
18
4 days ago
Activity icon

Started a new Conversation Ajax Callback

<div class="col-xs-12 col-sm-12 col-md-12 text-center ">
      <button  id="finish" class="btn btn-primary">finish</button>
 </div>

//script

 $('#addNew').click(function(cb){

    $.ajax({
 type:GET;
 url:'Get/local/'
 dataType:'json',
 data:form_data,
success:function(res){ 

cb(res); 
}
});

//and now I want to pass res I get to other function, and I try this, but not working

$('#finish').click(function(res){
console.log(res);

});

any help, please. res..give me data of an object. my problem is I am new to ajax and I don't know how to a callback res to other function

Feb
15
1 week ago
Activity icon

Replied to Tablular Format

console.log(res)

{id: 37, bookable_type: "App\Room", bookable_id: 2,....

res.id, res.no_date.... is working , but render many row ....

i try for loop

$.each(res, function (key, value) {
  for (key = 0; key < res.value.length; key++){
'<td id="row_'+rowCount+'" >' +rowCount+ '</td>'+
 '<td>' + res.value[key].id + '</td>'+
'<td>' + res.value[key].bookable_type + '</td>'+
....

not working say 'length' of undefined

Activity icon

Replied to Tablular Format

 var trHTML = '';
     $.each(res, function (i, item) {
      console.log(item.id);

console.log(item.id); i try this undefine , but in my crome response

{"id":13,"bookable_type":"App\Room",...

i also try console.log(item[0].id), but not working

Activity icon

Started a new Conversation Tablular Format

hello guys some issue in tablular format

<table id="org_table" class="display nowrap" style="width:100%">
  
                          <thead>

                           <tr>

                             <th>No</th>

                             <th>Org Name</th>
                           
                             <th>Type</th>.......
                        </tr>
                        </thead>
                        <tbody id="tBody"></tbody>
</table>

ajax blade code

 $('#addNew').click(function(){
                $.ajaxSetup({
                    headers: {
                      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                                   }
                   });// ajaxsetup
var rowCount=$("#org_table tbody tr").length+1; 
// ?organization="+orgID+'&name='+form_data,
                   $.ajax({
                          type:"POST",
                         url:"{{route('localBook.store')}}?user_type="+userType,
                                dataType:'json',
                                data:form_data,
                                success:function(res){ 


           var trHTML = '';
               $.each(res, function (i, item) {
                  trHTML += 
                   '<tr>'+
                      '<td id="row_'+rowCount+'" >' +rowCount+ '</td>'+
                       '<td>' + res.item.bookable.slug + '</td>'+
                       '<td>' + res.item.bookable_type + '</td>'+
                       '<td>' + res.item.bookable.slug + '</td>'+
                      '<td>' + res.item.no_date + '</td>'+
                      '<td>' + res.item.quantity + '</td>'+
                       '<td>' + res.item.bookable.room_price + '</td>'+
                       '<td>' + res.item.sub_total + '</td>'+
                       '<td>' + res.item.discount_amount + '</td>'+
                       '<td>' + res.item.discount_price_on_web + '</td>'+
                      '<th id="delete_'+rowCount+'" scope="row" class="delete_row" >'+remove+'</th>'+
                   '</tr>';
                       });
                $('#org_table tbody').append(trHTML);
                    }// function success 
                 });

        });// #add new

response on console crome

{"id":13,"bookable_type":"App\Room","bookable_id":2,"local_reservation_id":20,"booked_by":"37","name":null,"email":null,"user_id":null,"no_date":2,"quantity":1,"check_in":"2020-02-27 00:00:00",.....
}

my table is not showing up this is b/c post request???? or did i make mistake, thanks in adavance

Feb
13
1 week ago
Activity icon

Started a new Conversation Ajax Search

inside form tag i have a search field.

<div class="form-row ">

                     <div class="col-sm-6 col-md-2 col-lg-2 mb-4">
                        <div class="select-wrap">
                        
                          <input type="text" name="name" id="name" class="form-control" placeholder="Search By Name">
                         
                       </div>

                      </div>
  <div class="col-sm-6 col-md-2 col-lg-2 mb-4">
                        
                       <button id="search" class="btn btn-primary">Search</button>
                      </div> <!-- end of serach warap  -->
</div>

Ajax

function search(){
                          var form_data = {
                            search_name:$('#name').val(),
                            org_type:$('#type_of_organization').val(),
                            city:$('#city_id').val(),
                            type:$('#type').val(),
                            start_price:$('#amount_start').val(),
                            end_price:$('#amount_end').val(),
                            check_in:$('#check_in').val(),
                            check_out:$('#check_out').val(),
                          } //end of var

                        if(form_data){
                             $.ajax({
                                type:"GET",
                                url:"{{route('local.search')}}?search="+form_data,
                                dataType:'json',
                                data:form_data,
                                success:function(res){
console.log(res);
}

 function registorEvents(){
                    $(document).on('click','#search',search);
                }
                  registorEvents();

the problem is render blank page and change my url from ../book/create to../book

APIController

 public function localSearch(Request $request)
     { 
        

        if($request->ajax())
         {
             

                    $name=$request->get('name');
                    $org_type=$request->get('org_type');
                    $city=$request->get('city');
                    $type=$request->get('type');
                    $start_price=$request->get('start_price');
                    $end_price=$request->get('end_price');
                    $check_in=$request->get('check_in');
                    $check_out=$request->get('check_out');
.....

Route::get('api/local-search','[email protected]')->name('local.search');

Feb
08
2 weeks ago
Activity icon

Replied to Inside Where

@tisuchi it is not working error "mb_strpos() aspects parameter 1 to be string object given "

Activity icon

Started a new Conversation Inside Where

organization and individualRooms hasManyThrough Relationship. App/Organization::with('individualRooms')->get(); working fine.

      $orgAvailable = Organization::with('individualRooms')->where(function ($query) use ($individualRoomReserveId) {
    $query->whereNotIn('individualRooms.id', $individualRoomReserveId);
})->first();

my question is how can i use individualRooms column?? it shows me some error "individualRoom.id is not found in organization column."

any help, thanks

Feb
06
2 weeks ago
Activity icon

Started a new Conversation Relationship

$organization->room //conference ->booking // 1 to many polymorphic relationship room.php/model

 public function bookings()
    {
        return $this->morphMany('App\Booking', 'bookable');
    }
 public function organization()
    {
        return $this->belongsTo(Organization::class, 'organization_id');
    }

conference.php also similar with the room.php

the organization has 1 to many relationships with the room and conference.

my question is how can i get $organization->booking;

$organization->booking;

//i try hasManyThrough, but it only works either room or conference.

  public function booking()
     {
       return $this->hasManyThrough(Booking::class, Room::class, 'organization_id','bookable_id','id','id');
   } 

any help please, thanks

Feb
05
2 weeks ago
Activity icon

Replied to Array

@sinnbeck and @sti3bas thanks very much !!

Activity icon

Started a new Conversation Array

relationship booking.php //model

public function individualRooms()

    {
      return $this->belongsToMany(individualRoom::class,'booking__individualroom');
    }
 App\Booking::with('individualRooms')->get()

what i want is all the individual roooms and itry this

})->with('individualRooms')->get()->pluck('individualRooms','id')->toArray();

output

array:3 [▼
  2 => array:1 [▼
    0 => array:8 [▼
      "id" => 3
      "room_id" => 1
      "room_no" => 202
      "room_floor" => null
      "created_at" => "2020-01-26 16:02:39"
      "updated_at" => "2020-01-26 16:02:39"
      "deleted_at" => null
      "pivot" => array:2 [▶]
    ]
  ]
  3 => array:2 [▼
    0 => array:8 [▶]
    1 => array:8 [▶]
  ]
  4 => array:2 [▼
    0 => array:8 [▶]
    1 => array:8 [▶]
  ]
]

but what i need is

0 => array:8 [▼
    "id" => 8
    "room_id" => 1
    "room_no" => 401
    "room_floor" => null
    "created_at" => "2020-02-03 19:31:44"
    "updated_at" => "2020-02-03 19:31:44"
    "deleted_at" => null
    "pivot" => array:2 [▶]
  ]
  1 => array:8 [▼
    "id" => 3
    "room_id" => 1
    "room_no" => 202
    "room_floor" => null
    "created_at" => "2020-01-26 16:02:39"
    "updated_at" => "2020-01-26 16:02:39"
    "deleted_at" => null
    "pivot" => array:2 [▶]
  ]
2 => array:8 [▼
    "id" => 3
    "room_id" => 1
    "room_no" => 202
    "room_floor" => null
    "created_at" => "2020-01-26 16:02:39"
    "updated_at" => "2020-01-26 16:02:39"
    "deleted_at" => null
    "pivot" => array:2 [▶]
  ]

any help, please??

Feb
04
2 weeks ago
Activity icon

Replied to Query Filter

 })->with('individualRooms')->get()->pluck('individualRooms')->toArray();

out put

array:2 [▼
  0 => array:1 [▼
    0 => array:8 [▶]
  ]
  1 => array:2 [▼
    0 => array:8 [▶]
    1 => array:8 [▶]
  ]
]

using first

 })->with('individualRooms')->get()->pluck('individualRooms')->first()->toArray();

result

 0 => array:8 [▼
    "id" => 3
    "room_id" => 1
    "room_no" => 202
    "room_floor" => null
    "created_at" => "2020-01-26 16:02:39"
    "updated_at" => "2020-01-26 16:02:39"
    "deleted_at" => null
    "pivot" => array:2 [▶]
  ]
]

working fine, but only the "first array" show up to access room_no.

my question is how can i get all array and access "room_no" get list like pluck('id','room_no');

Feb
03
2 weeks ago
Activity icon

Started a new Conversation Query Filter

d/m/y . ... and 02/01/20 -03/01/20 room 101 booked.

14/01/20-21/01/20 101 and 201 booked.

my question is on 03/01/20 - 14/01/20 both 101 and 201 available, but in my query getting 101, 101, 201, is there is other way ???

$roomNotReserve =$room->bookings()
                  ->whereNotIn('book_status_id',$statusCollect)
                  ->where(function($q2) use ($check_in, $check_out) {

                        $q2->where('check_in','>=',$check_out) 
                           ->orWhere('check_out','<=',$check_in);
                    })->with('individualRooms')->get()->pluck('individualRooms')->toArray();
 $q2->where('check_in','>=',$check_out) 
                           ->orWhere('check_out','<=',$check_in);

not consider the repetition!! same room booked on the different dates are all show up.

Activity icon

Replied to Sync Many To Many

@ahmeddabak thanks for the reply

can you give some example? modelKeys()??

$booking->individualRooms()->sync($room->individualRoom->modelKeys()));

and one more how to count multiple selected fields. 1selected, 2 or 3 based multiple

 {!! Form::select('quantity', $result,[], array('class' => 'form-control','multiple')) !!}
Feb
02
2 weeks ago
Activity icon

Replied to Query

@ahmeddabak my problem is using merge method [0=>101,1=>102] and [1=>202,3=>402]. the merge result is like this[0=>101,1=>202,3=>402], but what i need is [0=>101,1=>102,2=>202,=>3=>402]. so merge method is not working for me.

i try use array_merge($array1,$array2 and put it inside collect[] and pluck('id',room_no). same result of the merge in the collection. my question using two collections and merge them together, why dont i create 1 collection using query builder, but i make somewhere mistake

for example

->where(function ($query,$status_id){ // show me some error 1 paramete expected error...extra  

the first two collective and merge work fine expect the out put i need with pluck('id','room_no'),


edit the second query to get the first result without using merge
Activity icon

Started a new Conversation Query

$status_id = BookStatus::where('name', 'Booked')->firstOrFail()->id;
        $check_in =$check['check_in'];
        $check_out=$check['check_out'];

$booking_id=$room->bookings()->with('individualRooms')->get();
      $booking_list=$booking_id->pluck('individual_rooms');

  $roomNeverBooking =$room->individualRooms()->whereNotIn('id',$booking_list)->get()->pluck('id','room_no');

         $roomNotReserve = $room->bookings()->with('individualRooms')->whereNotIn('bookings.book_status_id',[$status_id])

                         ->when(request(['check_in','check_out']), function($q){

                        return $q->where('bookings.check_out','=<', request('check_in'))
                              ->orWhere('bookings.check_in','>=',request('check_out'));
                               
               })->with('individualRooms')->get()->pluck('id','room_no');
            
       $result=$roomNeverBooking->merge($roomNotReserve); 

change this one line query how??????????

$roomNotReserve =$room->individualRooms()->whereNotIn('id',$booking_list)
                ->where(function ($query,$status_id){
                  $query->with('individualRooms')->whereNotIn('bookings.book_status_id',[$status_id])
                        ->when(request(['check_in','check_out']), function($q){

                          return $q->where('bookings.check_out','=<', request('check_in'))
                               ->orWhere('bookings.check_in','>=',request('check_out'));
                             });

                    })->get()->pluck('id','room_no');

        dd($roomNotReserve);// error 

edit the second query to give me the 1st output. :)

Activity icon

Started a new Conversation Query

sorry

Activity icon

Started a new Conversation Query

sorry

Feb
01
3 weeks ago
Activity icon

Started a new Conversation Sync Many To Many

hello guys

room parent has 5 room child. quantity count the room child show in front end. my question is if the customer choice quantity b/n 1 to 5 . let say the customer choice 3 and book the room. the first 3 room children save in pavot table of booking_Individual. how can i do this??

room(parent)->individualRoom(child) 1 to many relationship

$result=$room()->individiual_rooms_count()->get();

<div class="form-group">
            <strong>Quantity:</strong>
    

              <select  name="quantity" >   
                  @for($i=1; $i<=$result; $i++)  
                  <option  >{{$i}}</option>
                  @endfor
              </select>

    
        </div>

booking.php //model


    public function individualRooms()

    {
      return $this->belongsToMany(individualRoom::class,'booking__individualroom');
    }

storeBooking

$booking =$room->bookings()->create($booking);
 $booking->individualRooms()->sync([???]));

if the user select 2 quantity the store the first 2 individual room, if 3 quantity selected same the first 3 from the individualroom .....

Jan
31
3 weeks ago
Activity icon

Started a new Conversation WithCount

hey guys

organization->room->individualRoom

organization.php //model

Jan
22
1 month ago
Activity icon

Started a new Conversation Ajax Date Range

hello, guys, I am working on two data fields and get the available room without refresh page using ajax, but I encounter this problem.

   <strong>Start date:</strong>

           <div class="input-group date" data-provide="datepicker">
              <input type="text" name="check_in" class="form-control">
              <div class="input-group-addon">
                  <span class="glyphicon glyphicon-th"></span>
              </div>
          </div>

        </div>

        <div class="form-group">

            <strong>End date:</strong>

            <div class="input-group date" data-provide="datepicker">
              <input type="text" name="check_out" class="form-control">
              <div class="input-group-addon">
                  <span class="glyphicon glyphicon-th"></span>
              </div>
          </div>

        </div>

      

      <div class="form-group">

        <div class="form-group">
             <strong>Quantity:</strong>
              <select  name="quantity" >   
                  @for($i=1; $i<=$roomQuantity; $i++)
                  <option  >{{$i}}</option>
                  @endfor
              </select>
        </div>

but i want the quantity change as the data changes, so i update the code like this

<label>Check Out:</label>



<div class="input-group date" data-provide="datepicker">
    <input id="check_out" name="check_out" type="text" class="form-control">
    <div class="input-group-addon">
        <span class="glyphicon glyphicon-th"></span>
    </div>
</div>

<button type="button" name="filter" id="filter" class="btn btn-info btn-sm">Check Availabilty</button>

 <br>

<div class="form-group">
    <strong>Quantity:</strong>
<select  name="availableQuantity" id="availableQuantity" >   

</select>
</div>

@section('javascript')

 var _token = $('input[name="_token"]').val();

 availableQuantity();

 function availableQuantity(check_in = '', check_out = '')
 {
  $.ajax({
   url:"{{ route('available-quantity') }}",
   method:"POST",
   data:{check_in:check_in, check_out:check_out, _token:_token},
   dataType:"json",
   success:function(data)
   {
    var output = text(roomQuantity-data.quantity);
    // $('#availableQuantity').text(data.length);
    for(var count = 0; count <= output; count++)
    {
     $('#availableQuantity option[value=' + output+ ']').prop('Selected',true);
     // output += 'data[count]';
    //  output += '<td>' + data[count].post_title + '</td>';
    //  output += '<td>' + data[count].post_description + '</td>';
    //  output += '<td>' + data[count].date + '</td></tr>';
    // }
    // $('tbody').html(output);
   }
  })
 }

 $('#filter').click(function(){
  var check_in = $('#check_in').val();
  var check_out = $('#check_out').val();
  if(check_in != '' &&  check_out != '')
  {
   fetch_data(check_in, check_out);
  }
  else
  {
   alert('Both Date is required');
  }
 });

on ApiController

  public function availableQuantity(Request $request, Room $room)
    {

       if($request->ajax())
         {
            $roomQuantity=$room->quantity;

          if($request->check_in != '' && $request->check_out != '')
          {
            $status_id = BookStatus::where('name', 'Booked')->firstOrFail()->id;


            $data = $room->whereNotIn('id',App\Booking::select('id')->with('bookable')->where(function ($query) {
            $query->when(request(['check_in','check_out']), function($q){
                  return $q->where('bookable.check_out','=<', request('check_in'))
                               ->where('bookable.check_in','>=',request('check_out'))
                               ->where('bookable.book_status_id',$status_id);

                     });
            }))->get();

           } //end of if (request->request)
           else
           {
            //
           }
            return response()->json($data, $roomQuantity);

         
        } //end of if (request->ajax) 
    }

web

//ajax-availability 
Route::post('api/available-quantity','[email protected]')->name('available-quantity');

any help i am new to ajax , thanks

Jan
13
1 month ago
Activity icon

Replied to Update Value Inside Delete Method

@siangboon ok i am new and "Even with AI, system also need some sort of formulas or algorithms to make such decision" what is your suggestion any tutorial. in my case it checks start time and after 10 min it's going to be expired.

Activity icon

Replied to Update Value Inside Delete Method

what about using Task Scheduling.

Activity icon

Replied to Update Value Inside Delete Method

@bobbybouwmann ok thanks. how can i delete automatically without trigger delete button?

Activity icon

Started a new Conversation Update Value Inside Delete Method

my question is how to change a value in the delete method can i use an update inside the delete method?

 public function destroy(Room $room, $id)
    {
        $self=SelfBook::where('id',$id)->firstOrFail();
        
      
    
  
      
      
if($comparison)


    dd($self);
        $self->delete();

    }
Jan
11
1 month ago
Activity icon

Replied to Full Calendar

I am facing a situation of designing a booking system of a hotel website that may handle thousands and thousands of hotel rooms and their availability.

how can I achieve this kind of data table schema in Laravel

The matrix would look like the following:

id  Hotel   Room Type   Room    1/1/2020    2/1/2020    3/1/2020    4/1/2020    5/1/2020    6/1/2020    
1   A         SWEET      101      1          1                  
2   B         DOUBLE     102       0         1          
3   C         SINGLE     302       1         1

"1" mean booked and "0" mean not booked

Activity icon

Started a new Conversation Full Calendar

hello guys

I am trying to check availability of the room, my question is how can i achieve calendar with this column

id | room_no | day_1|day_2|day_3|day_4|day_5|day_6 ........................../every year | | | | | | |

if the room booked with date range the calendar will shade and with that specific room_no not available.

e.g

customer book room_no 101 for 2 days start date= 1/02/2020 end date 03/02/2020 on the calendar it shades the and room is not available

Activity icon

Replied to DataBase Structure

how to achieve this:

Typical queries one might expect in such as system are:

Is room X available at datetime Y for Z minutes?

Find a room that is available on a certain date.

Find the first available room (perhaps on a subset of floors or in a specific building)

Find all the bookings for a specific date.

Find all the bookings for a specific week.

Find all the bookings for a specific month.

Find all the booking for a specific room in a specific time period.

Activity icon

Replied to DataBase Structure

any help:)

Jan
10
1 month ago
Activity icon

Started a new Conversation DataBase Structure

i have this table and I have the problem of check availability in a range of date


room:

 -id
 -quantity
 -price
 -room_type_id(belongsTo) 
-organization_id(belongsTo)

*****
roomReservation: 

-id 
-check_in
 -check_out 
-quantity 
-sub_total 
-vat 
-total
-validation_code 
-user_id(belongsToMany)
 -room_id(belongsTo)
 -book_status_id( belongsTo)

****
roomTypes:

 -id 
-name
- desc
organization :
-id
 -region_id
 -city_id
 -averge_price
 -desc
  -is_feature

******
book_status:
 -id 
-name
 -desc

I struggle with check availability of rooms with check-in and checkout and while room reserve in specific input of check-in checkout the room quantity should decrease (room_quantity-reservation_quantity) in that time range. for me it hard:)

I try to "morph to" relationship like this room_table I add $table->morph("bookable"); on the reservation, I also add morph() for a user and bookable then I create a new table available (almost similar column like room reservation). still confuse.

and this makes me try marathon :).

any help, please !!

Jan
07
1 month ago
Activity icon

Started a new Conversation Redirect Login

hello guys:)

i try to a reservation and it checks if the user is login if its login proceeds the process if not it redirects to login and lets the user login after login it redirects to the reservation page. my problem is while it redirects to the login and the customer login it redirects to the normal login redirect page. how to solve this? on both login and registration.

Jan
05
1 month ago
Activity icon

Replied to Fetching Wrong Data

show me some code, please

Activity icon

Replied to Fetching Wrong Data

yes dd() it gives me always room5 ? the request always room5 inside the "A Hotel" the problem is in every hotel click the room give me the last hotel for all. here is extra code

parent Blade

  <div class="action">
              <a href="{{route('singleRoom.show', [$room->slug, $room->id])}}" class="btn btn-info">View Detail</a>
           
               <button type="button" class="btn btn-default" style="background-color:#ff9f1a; color: black" data-toggle="modal" data-target="#reserveForm">
                   Book Now<br> <span style="color: green; font-weight: bold;">5%-10% Off</span>
              </button>
          
            

            </div>



      <!-- Modal Confrence-->
<div class="modal fade" id="reserveForm" tabindex="-1" role="dialog" aria-labelledby="reservationForm" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="reservationForm">Get Rest Booking Service</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">

      
       @include('SelfBook.general')



</div>
</div>
</div>
</div>

selfBook.general blade

 @if ($room->quantity > 0)
                <form action="{{ route('selfBook.store', $room) }}" method="POST">
                    {{ csrf_field() }}
                    <button type="submit" class="button button-plain">Pay Later <br> <span>Valid Only for 20 Min</span></button>
                </form>
            @endif

web

Route::get('/room/{slug}/{id}', '[email protected]')->name('singleRoom.show');
Route::get('/conference/{slug}/{id}', '[email protected]')->name('singleConference.show');

//self Room
Route::get('/selfBook', '[email protected]')->name('selfBook.index');
Route::post('/selfBook/{room}', '[email protected]')->name('selfBook.store');
Route::patch('/selfBook/{room}', '[email protected]')->name('selfBook.update');
Route::delete('/selfBook/{room}', '[email protected]')->name('selfBook.destroy');
 public function store( Room $room)
    {
        dd($room);

         if(Auth::check())
        {
              $roomPrice=$room->room_price;
       $check_in=CarbonImmutable::now();
       $check_out=$check_in->add(1, 'day');
       $user_id=Auth::user()->id;
.
.
...
}

any help:)

Activity icon

Replied to Fetching Wrong Data

http://127.0.0.1:8000/selfBook/5

not change the {room} based on the click .how to fix any help?

Jan
04
1 month ago
Activity icon

Started a new Conversation Fetching Wrong Data

web.php

//self reservation
Route::post('/selfBook/{room}', '[email protected]')->name('selfBook.store');
Route::get('/selfBook/{room}', '[email protected]')->name('selfBook.create');// i pass room in create method b/c i use values of room while create new booking

blade file

 @if ($room->quantity > 0)
                <form action="{{ route('selfBook.create', $room) }}" method="GET">
                    {{ csrf_field() }}
                    <button type="submit" class="button button-plain">Pay Later <br> <span>Valid Only for 20 Min</span></button>
                </form>
            @endif

selfBook Controller

 public function create(Room $room)
    {
       dd($room);
....
}

my problem is fetching the last data in all children! when i click to single room type it shows me, master, if i click on the double it shows me, master. fetching only the master(last children).

Dec
29
1 month ago
Activity icon

Replied to Display Price Range In Blade File

any idea, please

Activity icon

Started a new Conversation Display Price Range In Blade File

in my template main_front.js

var siteSliderRange = function() {
    $( "#slider-range" ).slider({
      range: true,
      min: 10000,
      max: 1000000,
      values: [ 200000, 750000 ],
      slide: function( event, ui ) {
        $( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
      }
    });
    $( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
      " - $" + $( "#slider-range" ).slider( "values", 1 ) );
    };
    siteSliderRange();

search controller

$minPrice=Organization::min('avg_price');//400
      $maxPrice=Organization::max('avg_price');//2000

Blade.search

 <div class="col-sm-6 col-md-4 col-lg-3 mb-4">
            <div class="mb-4">
              <div id="slider-range" class="border-primary"></div>
              <input type="text"  name="text" id="amount" class="form-control border-0 pl-0 bg-white" disabled="" />
            </div>

          </div>

@push('javascript')
<script>
   var siteSliderRange = function() {
    $( "#slider-range" ).slider({
      range: true,
      min: $minPrice,
      max: $maxPrice,
      values: [ $minPrice, $maxPrice ],
      slide: function( event, ui ) {
        $( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
      }
    });
    $( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
      " - $" + $( "#slider-range" ).slider( "values", 1 ) );
  };
  siteSliderRange();
</script>
@endpush

i try to update the main_front.js using push method in blade, but is not working

any idea ?

Dec
27
1 month ago
Activity icon

Replied to GetFirstMediaUrl() On String

@nakov organization.php

 public function getGallaryAttribute()
    {
        $files = $this->getMedia('gallary');
        $files->each(function ($item) {
            $item->url       = $item->getUrl();
            $item->thumbnail = $item->getUrl('thumb');
        });

        return $files;
    }

on the database it store properly multiple images

Activity icon

Replied to GetFirstMediaUrl() On String

@nakov

<div class="site-blocks-cover" style="background-image: url('{{ $singleOrganization->getFirstMediaUrl('gallary')}}');" data-aos="fade" data-stellar-background-ratio="0.5">

gallary is the multiple image. but on the frontend only one image showup

Dec
26
1 month ago
Activity icon

Started a new Conversation GetFirstMediaUrl() On String

controller

public function show($slug, $id){
        
        $singleOrganization=Organization::where('slug',$slug)->where('id',$id)->firstOrFail();
        return view('singleOrganization', compact('singleOrganization'));
    }
@foreach ($singleOrg->getMedia('gallary') as $galleryItem)
            <div class="site-blocks-cover" style="background-image: url('{{ $galleryItem->getFullUrl() }}');"
                 data-aos="fade" data-stellar-background-ratio="0.5">
                 @endforeach

singleOrganization.blade

@foreach ($singleOrganization as $singleOrg )
            <div class="site-blocks-cover" style="background-image: url('{{ $singleOrg->getFirstMediaUrl('gallary') }}');"
                 data-aos="fade" data-stellar-background-ratio="0.5">
@endforeach

I try this, but it shows me some error "getFirstMediaUrl() on string"

Dec
25
1 month ago
Activity icon

Replied to Query On The Search

i have price slider range and how can i get the max and min from the database

<div class="mb-4">
              <div id="slider-range" class="border-primary"></div>
              <input type="text" name="text" id="amount" class="form-control border-0 pl-0 bg-white" disabled="" />
            </div>
          </div>

controller

$maxOrgPrice=Organization::?
$minOrgPrice=??
Activity icon

Replied to Query On The Search

@nakov thanks:)

Activity icon

Started a new Conversation Query On The Search

the organization has a child -room (one to many relationships with an organization) and on the organization, there is city_id field

search rooms with the city do not get any value

SearchRoomController

public function index(){

    $cities=City::all();
        $roomType=Roomtype::all();
        $rooms=Room::with('organization')
        ->when(request('room_type'), function($query){
            return $query->where('roomtype_id', request('room_type'));
        })
        ->when(request('city_id'),function($query){
                return $query->where('organization.city_id',request('city_id'));
            })

on the search blade

<div class="col-sm-6 col-md-4 col-lg-3 mb-4">
            <div class="select-wrap">
              <span class="icon icon-arrow_drop_down"></span>
              <select name="room_type" id="room_type" class="form-control d-block rounded-0">
                <option value="">--Room Type--</option>
              @foreach($typeOfRoom as $roomType)
                <option value="{{$roomType->id}}">{{$roomType->name}}</option>
               @endforeach
              </select>
            </div>
          </div>
         

          <div class="col-sm-6 col-md-4 col-lg-3 mb-4">
            <div class="select-wrap">
              <span class="icon icon-arrow_drop_down"></span>
              <select name="city_id" id="city_id" class="form-control d-block rounded-0">
                <option value="">--city--</option>
                @foreach($cities as $city)
                <option value="{{$city->id}}">{{$city->name}}</option>
                @endforeach
              </select>
            </div>
          </div>

organization.php

 public function rooms()
    {
        return $this->hasMany(Room::class);
    }

room.php

 public function organization()
    {
        return $this->belongsTo(Organization::class, 'organization_id');
    }

the error is where('organization.city_id', ....no column in the DB

Dec
23
1 month ago
Activity icon

Replied to Multiple Image

@nakov yes , [ 'key' => 'front_slider', 'value' => '', ], value store array .

<div class="slide-one-item home-slider owl-carousel">

  @foreach(config('app.settings') as $front)
                 <div class="site-blocks-cover" style="background-image: url('{{$front->config('settings.front_slider') }}');" data-aos="fade" data-stellar-background-ratio="0.5">
                 </div>
               @endforeach


    </div>
Activity icon

Replied to Multiple Image

@nakov I store the MULTIPLE image to config using service provider (settingServiceProvider).

i want to fetch in the frontend

"homeController"

  public function index()
    {
 $config=Config::settings();
        $fronts=$config->get('front_slider'); 
....
return view('home', compact('orgFeature','typeOfOrg','cities','featureOrgs','fronts'));

}

what i see config is not model . how can i make work in config files

home blade.php

@foreach($fronts as $front)
                 <div class="site-blocks-cover" style="background-image: url('{{$front->config('settings.front_slider') }}');" data-aos="fade" data-stellar-background-ratio="0.5">
                 </div>
 @endforeach

Dec
22
2 months ago
Activity icon

Replied to Multiple Image

add 1 file working and try to add more than 1 file show error of 404 not found