Melodia

at Home

Experience

6,530

0 Best Reply Awards

  • Member Since 5 Months Ago
  • 33 Lessons Completed
  • 0 Favorites

13th October, 2018

Melodia left a reply on How Can I Make A More Refine Search Result • 6 days ago

@D9705996 I followed your suggestion and it actually works now. Initialized all the variables and put a conditional statement in all the methods.

public function city_suburb($city = null){
    if(!$city) {
       return $this->builder;
    } 
    return $this->builder->where('city', $city)->orWhere('suburb', $city);
}

public function type($type = null){
    if(!$type) {
       return $this->builder;
    } 
    return $this->builder->where('type', $type);
}

public function min_price($price = 0){
    if(!$price) {
       return $this->builder;
    } 
    return $this->builder->where('price', '>=', $price);
}

 public function max_price($price = 0){
    if(!$price) {
       return $this->builder;
    } 
    return $this->builder->where('price', '<=', $price);
}

public function bathrooms($bathrooms = null){
    if(!$bathrooms) {
       return $this->builder;
    }       
    return $this->builder->where('bathrooms', $bathrooms);
}

public function bedrooms($bedrooms = null){
    if(!$bedrooms) {
       return $this->builder;
    }       
    return $this->builder->where('bedrooms', $bedrooms);
}

Melodia left a reply on How Can I Make A More Refine Search Result • 6 days ago

Sounds a bit odd. I attempted to initialise the price to zero, but it complained about the other methods. So intialized everything to null. But now if I just search for type, it gives me an empty array.

public function type($type){
    return $this->builder->where('type', $type);
}

public function min_price($price = 0){
    return $this->builder->where('price', '>=', $price);
}

public function max_price($price = 0){
    return $this->builder->where('price', '<=', $price);
}

public function bathrooms($bathrooms = null){
    return $this->builder->where('bathrooms', $bathrooms);
}

public function bedrooms($bedrooms = null){
    return $this->builder->where('bedrooms', $bedrooms);
}

Melodia left a reply on How Can I Make A More Refine Search Result • 6 days ago

I remember to have changed to that but it did not work. But I followed Jeffrey's tutorial and just trying to implement the way he explained.

All works, but only if I type the query in the url my self. If I user the form, it gives me this error:

 Too few arguments to function App\PropertyFilters::min_price(), 0 passed and exactly 1 expected

And the url converts into these:

http://owlcrest.local/search?city_suburb=&type=apartment&min_price=&max_price=&bedrooms=&bathrooms=

Which seems like all records are compulsory

My form looks like this:

{!! Form::open(['method' => 'GET', 'action'=>'[email protected]_page']) !!}
    <div class="row flex wrap">

        <div class="col-sm-10">
            <div class="search-input">
                {!! Form::text('city_suburb', null, ['class'=>'form-controla', 'placeholder'=>'Search for suburb']) !!}         
            </div>

            <div class="select-boxes">
                {!! Form::select('type', [''=>'Type of property'] + ['apartment'=>'Apartment', 'house'=>'House', 'plot'=>'Plot', 'smallholding'=>'Smallholding', 'commercial'=>'Commercial', 'townhouse'=>'Townhouse'], null, ['class'=>'form-']) !!}   

                {!! Form::select('min_price', [''=>'Minimum'] + [450000 => 'R 450 000', 5000000 => 'R 500 000', 1000000 => 'R 1 000 000',2000000 => 'R 2 000 000', 3000000 => 'R 3 000 000', 4000000 => 'R 4 000 000',5000000 => 'R 5 000 000', 6000000 => 'R 6 000 000',

], null, ['class'=>'form-']) !!} {!! Form::select('max_price', [''=>'Maximum'] + [450000 => 'R 450 000', 500000 => 'R 500 000', 1000000 => 'R 1 000 000',2000000 => 'R 2 000 000', 3000000 => 'R 3 000 000', 4000000 => 'R 4 000 000',5000000 => 'R 5 000 000', 6000000 => 'R 6 000 000', ], null, ['class'=>'form-']) !!} {!! Form::select('bedrooms', [''=>'Bedroom'] + [2=>'1+', 3=>'2+', 20=>'20+'], null, ['class'=>'form-']) !!} {!! Form::select('bathrooms', [''=>'bathroom'] + [2=>'1+', 3=>'2+', 20=>'20+'], null, ['class'=>'form-']) !!}

        <div class="col-sm-2">
            {!! Form::submit('Search', ['class'=>'search bg-brown']) !!}
            <button class="clear-filter button">Clear Filter</button>
        </div>                  
    </div>

{!! Form::close() !!}

My function in the search_page became like the one below:

public function search_page(PropertyFilters $filters)
{
   return Property::filter($filters)->get();
 
} 

PropertyFilters.php

class PropertyFilters extends QueryFilter
{

    public function type($type){
        return $this->builder->where('type', $type);
    }

    public function min_price($price){
        return $this->builder->where('price', '>=', $price);
    }

    public function max_price($price){
        return $this->builder->where('price', '<=', $price);
    }

    public function bathrooms($bathrooms){
        return $this->builder->where('bathrooms', $bathrooms);
    }

    public function bedrooms($bedrooms){
        return $this->builder->where('bedrooms', $bedrooms);
    }
}

QueryFilter.php

abstract class QueryFilter
{
    //
    protected $request;
    protected $builder;

    public function __construct(Request $request){
        $this->request = $request;
    }

    public function apply(Builder $builder){
        $this->builder = $builder;

        foreach($this->filters() as $name => $value){
            if(method_exists($this, $name)){
                call_user_func_array([$this, $name], array_filter([$value]));
            }
        }

        return $this->builder;
    }

    public function filters(){
        return $this->request->all();
    }
}

I guess this goes back to the question @Snapey asked previously: When a user enters different searches, are you wanting them to be AND (the reply must contain all the search terms) or OR (the reply contains any of the search terms).

So in this case the reply should only contain the the search terms.

Melodia left a reply on How Can I Make A More Refine Search Result • 6 days ago

@D9705996 Yes I watched the tutorial and my code is based on the first minutes of that tutorial if you take a look at that. But it feels weird to follow the advanced when the basic is not working.

Melodia left a reply on How Can I Make A More Refine Search Result • 1 week ago

The second url gives a result.

But now if I just type this:

http://owlcrest.local/search?max_price=200

It does not show valid data. I see properties that price are higher than 200

Melodia left a reply on How Can I Make A More Refine Search Result • 1 week ago

So, I now changed my method to this:

public function search_page(Request $request)
{
    $property = (new Property)->newQuery();
   
    if($request->exists('suburb')){
        $property->whereSuburb($request->suburb);
    }

    if($request->has('max_price')){
        $property->where('price', '<=', $request->max_price);
    }

    return $property->get();
 
}  

But this is what happens: The below works:

http://owlcrest.local/search?suburb=Kenilworth

But the below does not really work:

http://owlcrest.local/search?max_price=200

It returns me properties which the price are even 1554511

And if I search for this:

http://owlcrest.local/search?suburb=Kenilworth?max_price=52954

It does not return anything, which is not really right.

Melodia left a reply on How Can I Make A More Refine Search Result • 1 week ago

@Snapey I just changed my search:

  http://owlcrest.local/search?suburb=Kenilworth

But it still return all the properties from the table instead.

"When a user enters different searches, are you wanting them to be AND (the reply must contain all the search terms) or OR (the reply contains any of the search terms)."

The reply must contain any of the search term. Because I could search for a property by city only. Or could search property by city where min price is 200000dollars. Or I can just search for property by min price, and etc. Hope I managed to explain properly

"I don't know how you are sending kenilworth but it shouldn't have quotes around it? (those %22's)"

At the moment I am entering the url manually, just fo rtesting purposes.

Melodia started a new conversation How Can I Make A More Refine Search Result • 1 week ago

I am learning query strings and have an input form with multiple entries for search. One of them is max_price ad suburb.

When I search for all properties in Kenilworth, I see that the filter does not work because it shows me all the properties.

http://owlcrest.local/search?suburb=%22Kenilworth%22

At the moment this is what I have in my controller:

public function search_page(Request $request)
{
    $property = (new Property)->newQuery();
   
    if($request->exists('suburb')){
        $property->orderBy('id', 'desc');
    }

    if($request->has('max_price')){
        $property->where('price', '<=', $request->max_price);
    }

    return $property->get();
 
}

The route looks like this:

Route::get('/search', '[email protected]_page')->name('search-page');

So, I want to implement a search that handles all type of requests. A user should be capable of searching with max_price only, min_price, suburb, or all.

How can I go about that?

My function initially looked like the one below, and I had posted a question about that before, but it didnt give me correct results

public function search_page(Request $request)
{
    // validation ...
    $query = Property::query();

    if ($city = $request->input('city_suburb') ?? '')
    {
        $query->where('city', $city)
              ->orWhere('suburb', $city);
    }

    if ($type = $request->input('type') ?? '')
    {
        $query->where('type', $type);
    }

    // if none of them is null
    if (! (is_null($request->input('min_price')) && is_null($request->input('max_price')))) {
        // fetch all between min & max values
        $query->whereBetween('price', [$request->input('min_price'), $request->input('max_price')]);
    }
    // if just min_price is available (is not null)
    elseif (! is_null($request->input('min_price'))) {
        // fetch all greater than or equal to min_price
        $query->where('price', '>=', $request->input('min_price'));
    }
    // if just max_value is available (is not null)
    elseif (! is_null($request->input('max_price'))) {
        // fetch all lesser than or equal to max_value
        $query->where('price', '<=', $request->input('max_price'));
    }

    $properties = $query->orderBy('id', 'asc')->paginate(9);

    return view('pages.search', compact('properties'));     
}

Hope that someone can support on that.

12th October, 2018

Melodia left a reply on Quick Deploy Not Working • 1 week ago

I followed your instructions. Pasted the payload url in my new webhook, but noticed that it was deploying forever..like an endless loop

11th October, 2018

Melodia left a reply on Quick Deploy Not Working • 1 week ago

@shez1983 IS there a specific name for the Payload url?

10th October, 2018

Melodia started a new conversation Mail Queue Does Not Work • 1 week ago

I have a table for properties and for users. Everytime I change the status of a property to 1, I want to notify the user about the action. Initially it was working with the normal email, but now that I added queue, when I click to change status, the page refreshes but nothing happens.

This is how my method looks in the controller:

public function activate($id) {
    $property = Property::whereId($id)->first();
    $property->update(['status'=> 1]);
    Mail::queue(new PropertyActive($property));
    return redirect()->back();
}

The mailable:

public $property;
public function __construct($property) {

    $this->property = $property;
    $this->to($property->user->email, 'Owlcrest');
    $this->subject('Your property listing');
}

I first tried with ShouldQueue in the mailable but that didnt really work either.

I had noticed that my queue driver was still set to sync change to database:

QUEUE_DRIVER=database

Melodia left a reply on SQLSTATE[HY000] [2002] When Trying A Simple Get() Over A Table • 1 week ago

@stratboy One thing that I noticed is that you use the get method:

$associates = DB::table('associates'); dd($associates->get());

Ideally you should use all() because there is no where clause.

Do you see your associates table if you check your database? If you maybe delete all your tables including migrations, run this in your terminal.

composer dump-autoload 

And then

php artisan migrate

Also, and not that it should matter, is there a reason why you're not using eloquent?

9th October, 2018

Melodia left a reply on Quick Deploy Not Working • 1 week ago

@Cronix I actually deployed the site using this tutoral. It says that to enable quick deploy you just have to click under "enable quick deploy" and it should work. Actually the having to create a web hook was an answer given by someone from forge, but I just dont see that option in my github account.

Melodia left a reply on Quick Deploy Not Working • 1 week ago

When I click on quick deploy it works, but the same does not happen if I try to enable quick deploy. I read that I have to create a web hook on my github account.I must go to settings, developer settings and add webhook. But it happens that I do not see the option to Add a hook on my side

8th October, 2018

Melodia started a new conversation Quick Deploy Not Working • 1 week ago

I have a site running for a couple of days already and I noticed that my quick deploy never worked. Even though I clicked to enable quick deploy, I still have to manually deploy it.

Is there anything else that I need to configure for that to work?

7th October, 2018

Melodia started a new conversation How To Use ThisIsMe Api • 1 week ago

Am trying to use an api called thisisme and here the url: https://uat-api.thisisme.com/v2/

I deployed my website with Forge and to access the api, it states that I need to generate an ssl certificate pair and a Certificate Signing Request.

It happens that I already have an SSL certificate generated by Forge. Is it normal to have multiple SSL keys and CSR?

Where in the server do I generate the new SSL and CSR? In the root directory or must I run the command "cd mysite.co.za" and do everything under my current site?

Another question is that, since I am only allowed to make use of the API in live server, how is this going to work with my github commits?

5th October, 2018

Melodia left a reply on How To Create A Search Result Page With Multiple Queries • 2 weeks ago

Am back to testing my search results and somethings do look 100% right.

If I seach by suburb only, it works, if I search proerty type it also works, but when try to select min_price or/and max_price, bathrooms and bedrooms, I dont get the desired result.

My updated controller looks like this:

public function search_page(Request $request)
{
    // validation ...
    $query = Property::query();

    if ($city = $request->input('city') ?? '')
    {
        $query->where('city', $city)
    ->orWhere('suburb', $city);
    }

    if ($type = $request->input('type') ?? '')
    {
        $query->where('type', $type);
    }

    // if none of them is null
    if (! (is_null($request->input('min_price')) && is_null($request->input('max_price')))) {
        // fetch all between min & max values
        $query->whereBetween('price', [$request->input('min_price'), $request->input('max_price')]);
    }
    // if just min_price is available (is not null)
    elseif (! is_null($request->input('min_price'))) {
        // fetch all greater than or equal to min_price
        $query->where('price', '>=', $request->input('min_price'));
    }
    // if just max_value is available (is not null)
    elseif (! is_null($request->input('max_price'))) {
        // fetch all lesser than or equal to max_value
        $query->where('price', '<=', $request->input('max_price'));
    }

    $properties = $query->orderBy('id', 'asc')->paginate(9);

    return view('pages.search', compact('properties'));     
}

And below are the search inputs:

{!! Form::open(['method' => 'GET', 'action'=>'[email protected]_page']) !!}
    <div class="row flex wrap">

        <div class="col-sm-10">
            <div class="search-input">
                {!! Form::text('city', null, ['class'=>'form-controla', 'placeholder'=>'Search for area,city, or suburb']) !!}          
            </div>

            <div class="select-boxes">
                {!! Form::select('type', [''=>'Type of property'] + ['apartment'=>'Apartment', 'house'=>'House', 'plot'=>'Plot', 'smallholding'=>'Smallholding', 'commercial'=>'Commercial', 'townhouse'=>'Townhouse'], null, ['class'=>'form-']) !!}               
                {!! Form::select('min_price', [''=>'Minimum'] + [1=>'1', 20=>'20'], null, ['class'=>'form-']) !!}                       
                {!! Form::select('maxprice', [''=>'Maximum'] + [1=>'1', 20=>'20'], null, ['class'=>'form-']) !!}
                {!! Form::select('bedrooms', [''=>'Bedroom'] + [2=>'1+', 3=>'2+'], null, ['class'=>'form-']) !!}
                {!! Form::select('bathrooms', [''=>'bathroom'] + [2=>'1+', 3=>'2+'], null, ['class'=>'form-']) !!}
            </div>                                              
        </div>

        <div class="col-sm-2">
            {!! Form::submit('Search', ['class'=>'search bg-brown']) !!}
            <button class="clear-filter button">Clear Filter</button>
        </div>                  
    </div>

{!! Form::close() !!}

Hope someone can help

Melodia started a new conversation My Classes Are Not Getting Called When I Use Soap • 2 weeks ago

Has anyone perhaps used Soap in Laravel before?

I am try to integrate soap in my website but am facing a few issues. This is the process I followed:

Use the compoer command to install:

add service provider:

Artisaninweb\SoapWrapper\ServiceProvider::class,

Added alias

'SoapWrapper' => Artisaninweb\SoapWrapper\Facade\SoapWrapper::class,

Created the soap controller and it looks like the following:

4th October, 2018

Melodia left a reply on How Can I Save Multiple Checkbox Inputs In A Single Request • 2 weeks ago

@Cronix I checked the dd and here the results:

array:5 [▼
   "_token" => "t8dE2LYYvoHjOvXIAVB6bGTGWb9rj3LJjWgjPcAx"
   "property_id" => "22"
   "from" => array:6 [▼
   "Mon" => null
   "Tue" => null
   "Wed" => "12:00 AM"
   "Thu" => null
   "Fri" => null
   "Sun" => null
]
"to" => array:6 [▼
"Mon" => null
"Tue" => null
"Wed" => "08:30 AM"
"Thu" => null
"Fri" => null
"Sun" => null
]
"day" => array:2 [▼
"Tue" => "Tue"
"Wed" => "Wed"
]
]

1st October, 2018

Melodia left a reply on How Can I Access My Database • 2 weeks ago

So I dont add any A record to the Digital Ocean? And when I point the A record to the public IP given by forge, which is server name do I use? I only see the one given by forge: quaint_name, but that doesnt seem to be the right server name. I was trying to test now with my GoDaddy account

Melodia left a reply on How Can I Access My Database • 2 weeks ago

My only issue now is with Forge and the hosting

Melodia left a reply on How Can I Access My Database • 2 weeks ago

I will go for the migration method because as you mentioned seed is not production.

Melodia left a reply on How Can I Access My Database • 2 weeks ago

"Wouldn't you have an admin panel or something where admin can change that using a form? You shouldn't be using phpmyadmin or similar for stuff like that."

Yes I do have an admin panel. But it happens that when I uploaded the site to forge for the first, I had an empty database, so I had to create a user and make it admin. What I did is: I disabled the email verification and automatically assigned an admin. Then I rolled back to how it was and put my RegistrationController in the gitignore. But would there be a better better approach than that?

"Sure, look into mysqldump. Basically backup your current database and import it to the forge database."

Perfect, Will look into that.

"I doubt that is the right IP for your server. 127.x.x.x isn't publicly accessible. It's a loopback address, which would only be able to be accessed from the host itself. That refers to the local machine itself and not routeable via the internet."

That IP number is just an example.

Melodia left a reply on Correct View Caching Method? • 2 weeks ago

Learning from the documentation is the best way to master Laravel. Thanks @Cronix

Melodia started a new conversation How Can I Access My Database • 2 weeks ago

I am deploying a Laravel site for the first time but I have a few issues:

How can I access my database tables? For example when I register a user, I want to change his access rights to admin, but now, without using phpmyadmin I got confused?

Is there a way I can export content to the database?

Ultimately, when I created my server, it gave an IP address and there I have my default site. The domain was registered at 1-grid and the site being hosted by Digital Ocean. How can I hook up my domain to th IP address generated by forge?

I created an A record at digital ocean with mydomain.com and pointed to my new server 127.1.2.5, but this does not seem to be the right answer.

Hope someone can guide.

30th September, 2018

Melodia left a reply on Mailgun Gives 401 Unathorized Response • 2 weeks ago

I am using forge. So I.ll ssh into the server and do composer install

Melodia left a reply on Mailgun Gives 401 Unathorized Response • 2 weeks ago

@Snapey I managed to make it work with smtp using gmail account for now because I have to make a test on live environment, but I see that when a user registers, the system is back logging him in.

I then noticed that its probably because the vendor folder was not uploaded to the server. If it is not recommended to upload the vendor folder, how exctly can work around this issue?

Melodia left a reply on Mailgun Gives 401 Unathorized Response • 2 weeks ago

Right now I am trying this on localhost. Its best to test on localhost first because first I will still have to do some work offline and then push the changes to github.

29th September, 2018

Melodia started a new conversation Mailgun Gives 401 Unathorized Response • 2 weeks ago

I was using my gmail account to send emails while working on localhost, but after uploading to the server the emails weren't going and t would give me an error in the page, so I assume it has to do with google security and decided to use mailgun, which am currently testing on local environment.

I created a new email with my domain [email protected] for the mailgun account.

In the .env I have the following:

MAIL_DRIVER=mailgun MAILGUN_DOMAIN=sandbox16261edfb1b94ea960061b8ce6e.mailgun.org MAILGUN_SECRET=g333c6d0-46a333e32

Did the setup in mail.php

'driver' => env('MAIL_DRIVER', 'mailgun'),

'host' => env('MAIL_HOST', 'smtp.mailgun.org'),

'port' => env('MAIL_PORT', 587),

'from' => [
    'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
    'name' => env('MAIL_FROM_NAME', 'Admin'),
],

I also edited the services.php

'mailgun' => [
    'domain' => 'sandbox16ddd1edfb1dd4e9ab89addd061b8ce6e.mailgun.org',
    'secret' => 'bddddd0-46a0de32',
],

When I try to send a email I see the following error:

Client error: `POST https://api.mailgun.net/v3/sandbox16261edfb1b94e9ab89a960061b8ce6e.mailgun.org/messages.mime` resulted in a `401 UNAUTHORIZED` response:\n

Forbidden\n

Is there anything else that I need to do?

26th September, 2018

Melodia left a reply on How Can I Save Multiple Checkbox Inputs In A Single Request • 3 weeks ago

Not really the case and yes I made it a little confusing with the names. but I have it saved as from_time and to_time

if (count($days)) {
    foreach ($days as $key => $day) {
        Viewingdate::create([
            'property_id' => $request->property_id,
            'day' => $day,
            'from_time' => $froms[$key],
            'to_time' => $tos[$key],
        ]);
    }
}

Melodia left a reply on How Can I Save Multiple Checkbox Inputs In A Single Request • 3 weeks ago

Sorry I didnt notice the previous answer. And yes you are right:

<form method="post" action="{{route('viewing.store')}}">
    @csrf
    <input type="hidden" name="property_id" value="{{$property->id}}">

    @foreach ($days as $dayName => $dayAbbr)
    <div class="flddex">
        <label class="day">{{ $dayName }}</label>       
        <input type="checkbox" name="day[{{ $dayAbbr }}]" value="{{ $dayAbbr }}">
        <label>From</label>
        <input type="text" class="timepicker form-cont" name="from[{{ $dayAbbr }}]"></input>
        <label>To</label>
        <input type="text" class="timepicker form-cont" name="to[{{ $dayAbbr }}]"></input>                
    </div>
    @endforeach

    <button type="submit" class="btn1-primary btn1">Add</button>
</form>

    $days = $request->day;
    $froms = $request->from;
    $tos = $request->to;

    if (count($days)) {
        foreach ($days as $key => $day) {
            Viewingdate::create([
                'property_id' => $request->property_id,
                'day' => $day,
                'from' => $froms[$key],
                'to' => $tos[$key],
            ]);
        }
    }

It saves one record at the time. If I try select multiple rows then it gives integrity contraint error:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'from_time' cannot be null (SQL: insert into `viewingdates` (`property_id`, `day`, `from_time`, `to_time`, `updated_at`, `created_at`) values (21, Tue, , , 2018-09-26 20:17:26, 2018-09-26 20:17:26))

Melodia left a reply on How Can I Save Multiple Checkbox Inputs In A Single Request • 3 weeks ago

So in this case I have to save one row at the time.

I try doing that, but when I return a $request I can only get the day, and not the from and to.

{"_token":"rnKBPQJrJk8K5MlwNIe9tGdVHOQ7MzcWkEci2xmo","property_id":"21","from":null,"to":null,"day":"Thu"}

I replaced

<input type="text" class="timepicker form-cont" name="from[]"></input>

for this:

But it didnt make a difference in the error.

Melodia left a reply on How Can I Save Multiple Checkbox Inputs In A Single Request • 3 weeks ago

I just tried that:

public function store(Request $request)
{

    $days = $request->days;
    $froms = $request->from;
    $tos = $request->to;

    foreach ($days as $key => $day) {
        Viewingdate::create([
            'property_id' => $request->property_id,
            'day' => $day,
            'from' => $froms[$key],
            'to' => $tos[$key],
        ]);
    }
}

But it gives me an invalid argument error

Invalid argument supplied for foreach()

Melodia started a new conversation How Can I Save Multiple Checkbox Inputs In A Single Request • 3 weeks ago

I am doing a small booking system in which a user should capable of selecting the days and times of the week which the rooms are available for viewing. For that, I am using datepicker to capture the "from" and "to" dates, and I also show a list of days from Monday to Sunday.

What I want is to save all the records in a single request, at the moment my form looks like this:

<form method="post" action="{{route('viewing.store')}}">
    @csrf
    
    <div class="flddex">
        <label class="day">Monday</label>
        <input type="hidden" name="property_id" value="{{$property->id}}">
        <input type="checkbox" name="day[]" value="Mon">
        <label>From</label>
        <input type="text" class="timepicker form-cont" name="from[]"></input>
        <label>To</label>
        <input type="text" class="timepicker form-cont" name="to[]"></input>                
    </div>
    <div class="flddex">
        <label class="day">Tuesday</label>
        <input type="hidden" name="property_id" value="{{$property->id}}">
        <input type="checkbox" name="day[]" value="Tue">
        <label>From</label>
        <input type="text" class="timepicker form-cont" name="from[]"></input>
        <label>To</label>
        <input type="text" class="timepicker form-cont" name="to[]"></input>                
    </div>
    <div class="flddex">
        <label class="day">Wednesday</label>
        <input type="hidden" name="property_id" value="{{$property->id}}">
        <input type="checkbox" name="day[]" value="Wed">
        <label>From</label>
        <input type="text" class="timepicker form-cont" name="from[]"></input>
        <label>To</label>
        <input type="text" class="timepicker form-cont" name="to[]"></input>                
    </div>
    <div class="flddex">
        <label class="day">Thursday</label>
        <input type="hidden" name="property_id" value="{{$property->id}}">
        <input type="checkbox" name="day[]" value="Thu">
        <label>From</label>
        <input type="text" class="timepicker form-cont" name="from[]"></input>
        <label>To</label>
        <input type="text" class="timepicker form-cont" name="to[]"></input>                
    </div>
    <div class="flddex">
        <label class="day">Friday</label>
        <input type="hidden" name="property_id" value="{{$property->id}}">
        <input type="checkbox" name="day[]" value="Fri">
        <label>From</label>
        <input type="text" class="timepicker form-cont" name="from[]"></input>
        <label>To</label>
        <input type="text" class="timepicker form-cont" name="to[]"></input>                
    </div>
    <div class="flddex">
        <label class="day">Saturday</label>
        <input type="hidden" name="property_id" value="{{$property->id}}">
        <input type="checkbox" name="day[]" value="Sat">
        <label>From</label>
        <input type="text" class="timepicker form-cont" name="from[]"></input>
        <label>To</label>
        <input type="text" class="timepicker form-cont" name="to[]"></input>                
    </div>
    <div class="flddex">
        <label class="day">Sunday</label>
        <input type="hidden" name="property_id" value="{{$property->id}}">
        <input type="checkbox" name="day[]" value="Sun">
        <label>From</label>
        <input type="text" class="timepicker form-cont" name="from[]"></input>
        <label>To</label>
        <input type="text" class="timepicker form-cont" name="to[]"></input>                
    </div>

    <button type="submit" class="btn1-primary btn1">Add</button>
</form>

If it was on value it would have easy:

public function store(Request $request)
{
    $days = $request->day;
  
    foreach ($days as $day) {
        //then save to table here
    }

But now in this case is different. I want to save the day, from and to at once.

As result, I could have something like:

Viewings: Mon 8am - 3pm | Wed 9am - 12pm

I was trying to use nested foreach but I got really confused.

Hope someone can help

Melodia left a reply on I See Uncaught TypeError When I Use Timepicker In Laravel • 3 weeks ago

Yes. I had also tried that after the attempt via npm had failed. But your answer explained it all.

Melodia left a reply on I See Uncaught TypeError When I Use Timepicker In Laravel • 3 weeks ago

Here is my webpack:

mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css');

mix.styles([
    'resources/assets/css/libs/style.css',
    'resources/assets/css/libs/bootstrap.min.css',
    'resources/assets/css/libs/bootstrap-datetimepicker.min.css',
    'resources/assets/css/libs/pgwslider.min.css',
    'resources/assets/css/libs/slider.css',
    'resources/assets/css/libs/fonts.css',

], 'public/css/libs.css');


mix.scripts([
    'resources/assets/js/libs/jquery-3.3.1.min.js',
    'resources/assets/js/libs/bootstrap.js',
    'resources/assets/js/libs/bootstrap-datetimepicker.min.js',
    'resources/assets/js/libs/pgwslider.min.js',
    'resources/assets/js/libs/scripts.js',
    'resources/assets/js/libs/slider.js'

], 'public/js/libs.js');

I am using the timepicker function inside scripts.js

$(document).ready(function(){

$('input.timepicker').timepicker({});

//rest of javascript here
});

My template file looks like this, just in case needed:

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>{{ config('app.name', 'Laravel') }}</title>

    <!-- Scripts -->
    <script src="{{ asset('js/app.js') }}" defer></script>
    <script src="{{ asset('js/libs.js') }}" defer></script>

    <!-- Fonts -->
    <link rel="dns-prefetch" href="https://fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700|Open+Sans:300,400,600,700|Roboto:300,400,500,700,900" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

    <!-- Styles -->
    <link href="{{ asset('css/app.css') }}" rel="stylesheet">
    <link href="{{ asset('css/libs.css') }}" rel="stylesheet">
    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/timepicker/1.3.5/jquery.timepicker.min.css">
    
</head>
<body>
    <div id="app">
        @yield('content')
    </div>
    <script src="//cdnjs.cloudflare.com/ajax/libs/timepicker/1.3.5/jquery.timepicker.min.js"></script>

</body>
</html>

Melodia started a new conversation I See Uncaught TypeError When I Use Timepicker In Laravel • 3 weeks ago

I tested timepicker on my codepen and it works just fine. https://codepen.io/Sidney-Dev/pen/bxXvGb

Now, I am trying to do the same in my laravel site via cdn, but for some reason I see an UncaughtTypeError in my console.

Uncaught TypeError: $(...).timepicker is not a function

If I inspect the site, I can clearly see both the stylesheet and javascript links loaded. I have jquery compiled via webpack.

I had initially tried using timepicker via npm, but had no success on that either.

It is weird that I can use Datetimepicker, but cannot use timepicker cause I assume it is done the same way.

I remember to have ran into the same issue when I tried to datepicker and ended up having to move on, but now it's a problem which really needs to be fixed.

Anything I could have possibly done wrong?

Thanks in advance

23rd September, 2018

Melodia started a new conversation How Can I Update Multiple Tables In A Single Request • 3 weeks ago

I have a table that stores car details and one that stores car properties

A car has many properties, and properties belong to car.

I can When I add records to car table I also add the properties.

For the update, I would also like to be able to have the car and properties listed.

In the index view I have the following link, which takes me to the edit view:

<a class="btn1 btn1-primary" href="{{route('single.car.edit', $car->id)}}">Update</a>

In the controller I have this:

public function seller_car_edit($id){
    $car = Car::whereId($id)->first();
    return view('pages.seller.cars.edit', compact(car));
}

When I go to the edit view, I can see the current details of the car from the cars table, but not the current properties.

How can view the properties too? In a way, when I click update, it will do for the car as well as it's properties.

This is how the view looks like:

<div class="col-sm-12"> 
    {!! Form::model($car, ['method' => 'PUT', 'action'=>['[email protected]_car_update', $car->id], 'files'=>true]) !!}

    <div class="heading">
        {!! Form::text('brand', null, ['placeholder'=>'Car Brand', 'class'=>'form-control my-input']) !!}       
    </div>

    <div class="features">
        {!! Form::text('accident', null, ['placeholder'=>'Accident before?', 'class'=>'form-control my-input']) !!}     
    </div>

20th September, 2018

Melodia started a new conversation Do I Have To Learn PhP • 4 weeks ago

During my studies I learned to program in various languages such Java, C+ and Visual Basic. At the same time I also learned database principles. But when I started web development was as a WordPress developer, afterwards I got borred and wanted to learn Php, but ended up straight into Laravel(recently).

Do I have to learn PhP to be good at Laravel or is it enough that I have an understanding of OOP?

Why would I learn PhP?

19th September, 2018

Melodia left a reply on Laravel Deployment Gives 500 Internal Server Error • 1 month ago

The last one worked:

require __DIR__.'/../../owlcrest/vendor/autoload.php';
$app = require_once __DIR__.'/../../owlcrest/bootstrap/app.php';

You really saved my day. Appreciate the support

Melodia left a reply on Laravel Deployment Gives 500 Internal Server Error • 1 month ago

No @lostdreamer_nl The project is in the root directory, and I named it owlcrest. In the public_html, I create another folder called owlcrest, which has all the content inside te public folder of the project.

Hope I could explain better

Melodia started a new conversation Laravel Deployment Gives 500 Internal Server Error • 1 month ago

I am trying to upload a laravel site to GoDaddy but I get an internal server error.

owlcrest.sidneylab.com

1 - I uploaded the folder of my project to the root directory 2 - Copied the content of the public folder inside a folder in my public_html folder 3 - I changed the index.php to the following:

require __DIR__.'/../owlcrest/vendor/autoload.php';

$app = require_once __DIR__.'/../owlcrest/bootstrap/app.php';

I have composer installed and updated.

Created the database and assigned it to a user.

The .env file configurations are set and I generated a new key.

Anything else I am posssibly missing?

17th September, 2018

Melodia left a reply on How Can I Block The Guard When Registering A User • 1 month ago

I had to restart my application and only then was able to access the RegistersUSers trait and comment the line tht has the guard. But guess it worked posting cause I got me hooked to the new version.

Here complete steps for the upgrade: https://laravel.com/docs/5.7/upgrade

Thanks @D9705996

Melodia started a new conversation How Can I Block The Guard When Registering A User • 1 month ago

I am using default laravel registration and everytime I register a user, the system currently logs him in, which I dont want.

For some reason I thought I had this working but now testing I see the issue. Below is my register controller and I hope someone can help.

<?php

namespace App\Http\Controllers\Auth;

use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\Request;
use Illuminate\Auth\Events\Registered;
use Illuminate\Support\Str;
use Mail;
use App\Mail\verifyEmail;
use Illuminate\Support\Facades\Session;

class RegisterController extends Controller
{

    use RegistersUsers;

    protected $redirectTo = '/';

    public function __construct()
    {
        $this->middleware('guest');
    }

    protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => 'required|string|max:255',
            'email' => 'required|string|email|max:255|unique:users',
            'password' => 'required|string|min:6|confirmed',
        ]);
    }

    protected function create(array $data)
    {
        $user = User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
            'verifytoken' => Str::random(40),
            'role_id' => $data['role_id']
        ]);
        $thisUser = User::findOrFail($user->id);
        Session::flush('status', 'Please verify your email for account activation');
        $this->sendEmail($thisUser);

        return $user;
    }

    public function sendEmail($thisUser){
        Mail::to($thisUser['email'])->send(new verifyEmail($thisUser));
    }

    public function sendEmailDone($email, $verifytoken){

        User::where(['email'=>$email, 'verifytoken'=>$verifytoken])->update(['status'=>'1', 'verifytoken'=>NULL]);

        return redirect('/login');

    }

    public function verifyEmail(){
        return view('emails.veryEmail');
    }
}

User registers, an email is sent to him with a token, and he should only be allowed to login after he activates the token via email.

The only problem here is that the user is currently being logged in automatically.

I know there is line with the guard that normally logs the user, but I do not even have that.

Melodia left a reply on How Can I Access Data Via Relationship • 1 month ago

One of te things that I was failing to do is to loop through the offers collection;

@if($properties)
@php ($i = 1)
<ul>
    @foreach($properties as $property)
            @foreach ($property->offers as $offer)
                <li>Offer {{ $i++ }}: {{$offer->offer_message}}</li>
            @endforeach
    @endforeach
</ul>
@endif

Then in the controller I did this as both @Cronix and @Snapey logic suggested:

$properties = Property::whereUserId(Auth::id())->has('offers')->get();

Appreciate the support

16th September, 2018

Melodia left a reply on How Can I Access Data Via Relationship • 1 month ago

No no, this will give the wrong data. Because an offer is placed by a different user, towards a property that is owned by another user. So, as the owner of the property, I want to ee all the offers placed towards my properties.

Melodia started a new conversation How Can I Access Data Via Relationship • 1 month ago

I have a user that has many properties. This is user should also be able tp view the offers bet on his properties.

So have the relationship set.

User.php

public function properties(){
    return $this->hasMany('App\Property');
}

Property.php

public function offers(){
    return $this->hasMany('App\Offer');
}

Then in my controller this is what I have:

public function my_offers(){
    
    $properties = Property::whereUserId(Auth::id())->get();


    return view('pages.seller.offers.index', compact('properties'));
}

Then I go to my views like this:

@if($properties)
<ul>
    @foreach($properties as $property)

        <li>{{$property->offers->offer_message}}</li>

    @endforeach
</ul>
@endif 

When I view the page I see the below error:

Property [offer_message] does not exist on this collection instance.

But this property exists in my table.

If I change my list item to the one below I can see the array:

 <li>{{$property->offers-}}</li>

I also see that before and after the array with the data, there are two empty arrays.

Is there anything that I didnt correctly?

Hope someone can help

14th September, 2018

Melodia started a new conversation How Can I Publish My Default Configurations Files • 1 month ago

I am trying to use this package: https://packagist.org/packages/billowapp/payfast

I first installed the composer, great. But now when I try to publish the configuration file this is what happens:

$ php artisan vendor:publish

Which provider or tag's files would you like to publish?:
[0 ] Publish files from all providers and tags listed below
[1 ] Provider: Barryvdh\DomPDF\ServiceProvider
[2 ] Provider: Billow\PayfastServiceProvider
[3 ] Provider: Fideloper\Proxy\TrustedProxyServiceProvider
[4 ] Provider: Illuminate\Mail\MailServiceProvider
[5 ] Provider: Illuminate\Notifications\NotificationServiceProvider
[6 ] Provider: Illuminate\Pagination\PaginationServiceProvider
[7 ] Provider: Laravel\Tinker\TinkerServiceProvider
[8 ] Tag: config
[9 ] Tag: laravel-mail
[10] Tag: laravel-notifications
[11] Tag: laravel-pagination

I choose option 2 or even 0. It says publisng complete. When I open the config folder, I do not see the payfast.php. Is there a reason why this is not happening?

Note: When I try in a different site it works, and the laravel version is the same: 5.6

12th September, 2018

Melodia left a reply on How To Delete After A Given Lapse Period If Status Isnt Updated • 1 month ago

Copy and paste issues

Melodia left a reply on How To Delete After A Given Lapse Period If Status Isnt Updated • 1 month ago

@Cronix yes edited my question based on your answer. Trying to make the code work I noticed that I dont need status field and not even the expires_at. Instead, I use the default timestamp( updated_at ) and my controller ended up being like this based on @cmdobueno answer.

protected function schedule(Schedule $schedule)
{
  $schedule->call(function () {

    Task::where('expires_at', '<', \Carbon\Carbon::now() )->delete();
    
  })->everyMinute();
}

The in my controller I just have this:

public function store(Request $request)
{        
    Task::create($request->all());
    return redirect()->back();
}
Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.