deladels

Experience

1,440

0 Best Reply Awards

  • Member Since 3 Months Ago
  • 2 Lessons Completed
  • 0 Favorites

16th January, 2018

deladels left a reply on Issue Using Mailable And Markdowns • 5 days ago

@Snapey thanks so much for your help. it works just fine. :)

deladels left a reply on Issue Using Mailable And Markdowns • 6 days ago

@Snapey how do you suggest i go about it?

BookingsController.php

<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controllers;

use Illuminate\Http\Request;

use Braintree_Transaction;

use App\Booking;

use App\Schedule;

use Session;

use Mail;

use App\Mail\ScheduleBooked;

class BookingsController extends Controller
{ 

    public function store(Schedule $schedule, Request $request){

        $this->validate( request(), [

            'lastName'        => 'required',
            'firstName'       => 'required',
            'email'           => 'required',
            'mobilenumber'    => 'required',
            'additionalId'    => 'required|max:13',
            'idNumber'        => 'required'

        ]);

        Booking::create([

            'schedule_id'   => $schedule->id,
            'lastname'      => request('lastName'),
            'firstname'     => request('firstName'),
            'email'         => request('email'),
            'mobilenumber'  => request('mobilenumber'),
            'id_type'       => request('additionalId'),
            'id_number'     => request('idNumber')

        ]);

        $result = Braintree_Transaction::sale([
                      'amount' => $schedule->price,
                      'paymentMethodNonce' => $request->payment_method_nonce,
                      'customer' => [
                        'firstName'  => $request->firstName,
                        'lastName'   => $request->lastName,
                        'phone'      => $request->mobilenumber,
                        'email'      => $request->email
                      ],
                      'options' => [
                        'submitForSettlement' => true,
                      ]
        ]);

        //Mail::to($request->email)->send(new ScheduleBooked);

        if (!$result->success) {

            \Session::flash('flash_message', 'Your Booking was not Successfull, please try again or contact us for help');
            
            return redirect('uschedule/{schedule}');
        }
        
        \Session::flash('flash_message', 'Your Booking has been Successfull');

        return redirect('uschedules');
    }    



    public function email(Request $request, $bookingId){

        $booking = Booking::find($bookingId);

        Mail::to($request->email)->send(new ScheduleBooked($booking));

        return redirect('/uschedules');
    }
}

15th January, 2018

deladels left a reply on Issue Using Mailable And Markdowns • 6 days ago

It'll be hit when the user clicks on the submit/book button

The method is called within the bookingcontroller class.

deladels left a reply on Issue Using Mailable And Markdowns • 6 days ago

So you are not calling the email route? yeah. looks like i am not hitting/calling it.

deladels left a reply on Issue Using Mailable And Markdowns • 6 days ago

and yes $request->email contains and email address

deladels left a reply on Issue Using Mailable And Markdowns • 6 days ago

@Snapey i actually did that. nothing is dumped. but like i said. putting the using the Mail facade directly in the store function sends an email.

deladels left a reply on Issue Using Mailable And Markdowns • 6 days ago

@bobbybouwmann yes i am. i configured everything. crosschecked it. i realised that when i i place or do this Mail::to($request->email)->send(new ScheduleBooked()); within the store function of the BookingsController it fires the email.

2.No please. i have nothing on queues set up at the moment.

deladels started a new conversation Issue Using Mailable And Markdowns • 6 days ago

i am trying to send an email when a users books a schedule. (i want to use the simple way so this is triggered when a button is clicked)

BookingController.php

    public function email(Request $request, $bookingId){

        $booking = Booking::find($bookingId);

        Mail::to($request->email)->send(new ScheduleBooked($booking));

        return redirect('uschedules');
    }

ScheduleBooked.php (Mailable)

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Booking;

class ScheduleBooked extends Mailable
{
    use Queueable, SerializesModels;


    public $booking;



    public function __construct(Booking $booking)
    {
        $this->booking = $booking;
    }

    public function build()
    {
        return $this->markdown('emails.schedules.booked')->with([

                        'lastname'  => $this->booking->lastName,
                        'firstname' => $this->booking->firstName,
        ]);
    }
}

route file.

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

i don't get any errors but the emails aren't being sent to my mailtrap.

12th January, 2018

deladels left a reply on Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No Message Error • 1 week ago

@bestmomo yes i do.

edit.blade.php

<form class="col 12" method="POST" style="padding-top: 20px;">
    {{ csrf_field() }}
    {{ method_field('PUT') }}
    
    <div class="container">
        <div class="row">
            <div class="input-field col s6">
                <input class="validate" type="text" name="busRegNo" value="{{ $adminBus->reg_number }}"></input>
                <label><b>Registration Number</b></label>
            </div>
            <div class="input-field col s6">
                <input class="validate" type="text" name="busModel" value="{{ $adminBus->model }}"></input>
                <label><b>Model</b></label>
            </div>
        </div>
        <div class="row">
            <div class="input-field col s6">
                <input class="validate" name="capacity" type="number" value="{{ $adminBus->capacity }}"></input>
                <label for=""><b>Capcity</b></label>
            </div>
            <div class="input-field col s6">
                
            </div>
        </div>
        <div class="row">
            <div class="col offset-m2 m4">
                  <button class=" red darken-1 btn waves-effect waves-light" type="submit">SUBMIT<i class="material-icons right">send</i>
                  </button>
            </div>
         </div>
    </div>
        </div>
    </div>
</form>

create.blade.php


<form class="col 12" method="POST" action="">
    {{ csrf_field() }}
    <div class="container">
        <h5 class="center-align">Add A New Bus</h5>
        <div class="row">
            <div class="input-field col s6">
                <input class="validate" type="text" name="busRegNo"></input>
                <label><b>Registration Number</b></label>
            </div>
            <div class="input-field col s6">
                <input class="validate" type="text" name="busModel"></input>
                <label><b>Model</b></label>
            </div>
        </div>
        <div class="row">
            <div class="input-field col s6">
                <input class="validate" name="capacity" type="number"></input>
                <label for=""><b>Capacity</b></label>
            </div>
            <div class="input-field col s6">
                
            </div>
        </div>
        <div class="row">
            <div class="col offset-m2 m4">
                  <button class=" red darken-1 btn waves-effect waves-light" type="submit">SUBMIT<i class="material-icons right">send</i>
                  </button>
            </div>
         </div>
    </div>
        </div>
    </div>
</form>

``

deladels started a new conversation Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No Message Error • 1 week ago

so i am trying to build a crude system. the index method works or more like all the get methods/verbs work. but anytime i try to submit a form or edit an entry i get the above error.

namespace App\Http\Controllers;

use App\AdminBus;

use Illuminate\Http\Request;

class AdminBusController extends Controller
{

    //function/action to get all buses in the db
    public function index(AdminBus $addbus)
    {
        $addbus = AdminBus::all();

        return view('admin.addbus.index', compact('addbus'));
    }


    //function/action to create a new bus
    public function create()
    {
        return view('admin.addbus.create');
    }

    public function store(Request $request)
    {
       $this->validate( request(), [

            'busRegNo'  => 'required',
            'busModel'  => 'required',
            'capacity'  => 'required'

        ]);

        AdminBus::create([

        'reg_number'  => request('busRegNo'),
        'model'       => request('busModel'),
        'capacity'    => request('capacity')

    ]);
            Session::flash('message', 'Successfully created nerd!');
            return Redirect::to('bus'); 
    }

    
    public function show($adminBus)
    {
        $adminBus = AdminBus::find($adminBus);

        return view('admin.addbus.show', compact('adminBus'));
    }

  
    public function edit($adminBus)
    {
        $adminBus = AdminBus::find($adminBus);

        return view('admin.addbus.edit', compact('adminBus'));
    }


    public function update(Request $request, AdminBus $adminBus)
    {
        $adminBus = AdminBus::find($adminBus);

       $this->validate( request(), [

            'busRegNo'  => 'required',
            'busModel'  => 'required',
            'capacity'  => 'required'

        ]);
       
        $adminBus->reg_number = $request->get('reg_number');
        $adminBus->model      = $request->get('model');
        $adminBus->capacity   = $request->get('capacity');
        $adminBus->save();

            Session::flash('message', 'Successfully created nerd!');
            return Redirect::to('bus');
    }

web.php file

Route::resource('bus', 'AdminBusController');

any help?

10th January, 2018

deladels left a reply on Is It Possible To Pass Variables Like This • 1 week ago

thank you @shez1983. all the best with all your "development" or "coding" sense.

deladels left a reply on Is It Possible To Pass Variables Like This • 1 week ago

lol seriously guys?

people say this a lot about guys who are good developers.

this might not be an excuse but i am just a student who was asked to use laravel for his project work. i am very much new to this. anyway thanks @tykus .

i have figured it out.

deladels left a reply on Is It Possible To Pass Variables Like This • 1 week ago

'[email protected]' shows all schedules.

the second one. the uri is to redirect users to that page after a successful login I'm using that to redirect based on the account type in my adminlogin controller. so if the account is a user he is sent to the schedules page but if its an admin he is sent to the dashboard.

deladels left a reply on Is It Possible To Pass Variables Like This • 1 week ago

very much understood. any suggestions?

deladels left a reply on Is It Possible To Pass Variables Like This • 1 week ago

UPDATED

Route::get('/schedules', '[email protected]'); was duplicated during copy and paste

so i have another route like that being accessed by another controller. could that be the error?

my route file


Route::get('/schedules', '[email protected]');

Route::get('schedule/{schedule}', '[email protected]');


Route::get('/braintree/token','[email protected]');

Route::post('/login/custom', [
    'uses' => '[email protected]',
    'as'   => 'login.custom'
]);
Route::group(['middleware' => 'auth'], function() {

Route::get('schedules', function() {
    dd(__FILE__);

});


    Route::get('dashboard', function() {
        return view('dashboard');
    });

});

deladels left a reply on Is It Possible To Pass Variables Like This • 1 week ago

first time using laravel. exactly why i am here for help .

deladels left a reply on Is It Possible To Pass Variables Like This • 1 week ago

so i have another route like that being accessed by another controller. could that be the error?

my route file


Route::get('/schedules', '[email protected]');

Route::get('schedule/{schedule}', '[email protected]');

Route::get('/schedules', '[email protected]');

Route::get('/braintree/token','[email protected]');

Route::post('/login/custom', [
    'uses' => '[email protected]',
    'as'   => 'login.custom'
]);
Route::group(['middleware' => 'auth'], function() {

Route::get('schedules', function() {
    dd(__FILE__);

});


    Route::get('dashboard', function() {
        return view('dashboard');
    });

});

deladels left a reply on Is It Possible To Pass Variables Like This • 1 week ago

yes @jorpedito . but there are records in there. a lot.

Route::get('schedules', function() {
    $schedules = App\Schedule::all(); // or whatever your query is...

   dd($schedules);

    return view('schedules', compact('schedules'));
});

same error for this dd is working.

deladels left a reply on Is It Possible To Pass Variables Like This • 1 week ago

yes not working with the same error as before.

tried this: not working.

Route::get('schedules', function() {
    $schedules = App\Schedule::all(); // or whatever your query is...
    return view('schedules', compact('schedules'));
});

i am trying to route a user the schedules page which will display all scheduled in the database. i have a loop in the blade file with the $schedules variable. that's where the error is coming form.

    <table class="striped center responsive-table">
        <thead>
                <th>FROM</th>
                <th>TO</th>
                <th>DEPARTURE DATE</th>
                <th>DEPARTURE TIME</th>
                <th>BUS NO.</th>
                <th>PRICE</th>              
        </thead>
        <tbody>
            @foreach ($schedules as $schedule)
                <tr>
                    <td>{{ $schedule->departure_location }}</td>
                    <td>{{ $schedule->destination_location }}</td>
                    <td>{{ \Carbon\Carbon::parse($schedule->departure_date)->format('M d Y') }}</td>
                    <td>{{ date("h:i a", strtotime($schedule->departure_time)) }}</td>
                    <td>{{ $schedule->bus}}</td>
                    <td>{{ $schedule->price}}</td>
                    <td> <a href="schedule/{{$schedule->id }}" class="btn waves-effect red darken-1">BOOK</a> </td>
                </tr>
            @endforeach
        </tbody>
    </table>

deladels left a reply on Is It Possible To Pass Variables Like This • 1 week ago

so all 4 alternatives are not working unfortunately

deladels left a reply on Is It Possible To Pass Variables Like This • 1 week ago

i just did.

i get this error when trying to view the schedules.blade.php file.

Undefined variable: schedules (View: C:\xampp\htdocs\BusTravel\resources\views\schedules.blade.php)

deladels started a new conversation Is It Possible To Pass Variables Like This • 1 week ago

    Route::get('schedules', function(App\Schedule $schedules) {
        return view('schedules')->with($schedules);
    });

is this possible?

deladels left a reply on Route Not Redirecting • 1 week ago

not working @bipin

deladels left a reply on Route Not Redirecting • 1 week ago

@bipin still not working

deladels left a reply on Route Not Redirecting • 1 week ago

@bipin i dont really get where you want me to put the first block of code. And the second one did not work. Still redirecting to the adminlogin page

deladels left a reply on Route Not Redirecting • 1 week ago

tried yours @tisuchi did not work.

tried yours too @Ishatanjeeb. it keeps redirecting back to the login page

9th January, 2018

deladels started a new conversation Route Not Redirecting • 1 week ago

when i enter the email and password, i dont get redirected to the dashboard. i can not seem to figure out what is happening.

route.php file

Route::prefix('admin')->group(function(){
Route::get('/login', 'Auth\[email protected]')->name('admin.login');
Route::post('/login', 'Auth\[email protected]')->name('admin.login.submit');
Route::get('/', '[email protected]')->name('admin.dashboard');
});

AdminController.php

class AdminController extends Controller
{
   
    public function __construct()
    {
        $this->middleware('auth:admin');
    }

  
    public function index()
    {
        return view('admin');
    }
}

AdminLoginController.php

class AdminLoginController extends Controller
{
    public function __construct(){

        $this->middleware('guest:admin');
    }

    public function showLoginForm(){

        return view('auth/admin-login');
    }

    public function login(Request $request){

        //validate the form input data
        $this->validate( request(), [
            'email' => 'required',
            'password' => 'required'

        ]);


        if(Auth::guard('admin')->attempt(['email' => $request->email, 'password' => $request->password], $request->remember)){

            return edirect()->intended(route('admin.dashboard'));

        }else{

            return redirect()->back()->withInput($request->only('email', 'remember'));

            }
        }
        
}

Admin.php (model)

class Admin extends Authenticatable
{
    use Notifiable;

    protected $guard = 'admin';


    protected $fillable = [
        'name','email', 'password',
    ];

 
    protected $hidden = [
        'password', 'remember_token',
    ];
}

deladels left a reply on Suggestion On Rerouting Users To Loginpage And Rerouting Back To Their Previous Page. • 1 week ago

is it possible to do something like this?

<input class="validate" type="text" name="lastName" placeholder="Enter Last Name" value="{{ Session::get('lastName') }}">

8th January, 2018

deladels left a reply on Suggestion On Rerouting Users To Loginpage And Rerouting Back To Their Previous Page. • 1 week ago

oh okay. that will mean i have to manually put the values into the session.cuz when i do a dd() i get null atm.

deladels started a new conversation Suggestion On Rerouting Users To Loginpage And Rerouting Back To Their Previous Page. • 1 week ago

so while working on my final year project, i decided to allow the users to browse through the up without having to be logged in since theres's this thing in UX/UI that says forcing users to login before viewing anything on an app is a deterrent.

so i am asking for you options on how to allow the user to browse through till where they'll have to make a booking or lets say till they get to the checkout page for example. now before they click on the place order button, i want to redirect them to login or register page and then sending them back to the order page.

any suggestions will be grateful.

7th January, 2018

deladels left a reply on Is It Possible To Pass The Same Uri To 2 Different Methods Ina Single Controller • 2 weeks ago

yeah i realised that. from bottom up i guess. @tykus any suggestions on how to go about this?

deladels started a new conversation Is It Possible To Pass The Same Uri To 2 Different Methods Ina Single Controller • 2 weeks ago

route file:

Route::post('schedule/{schedule}', '[email protected]')->name('book.pay');

Route::post('schedule/{schedule}', '[email protected]')->name('book.store');

blade file:

{{ csrf_field() }}

6th January, 2018

deladels left a reply on Extracting Values From Url And Updating Table In Db • 2 weeks ago

@Drfraker thanks very much. this worked flawlessly.

deladels left a reply on Passing Data From Blade To Controller • 2 weeks ago

hi , i know this may be old but i find myself having a similar issue and i want to ask a question.

after getting the parameters, is there any where of passing the parameter to your model to be inserted into a table or use the parameter in a controller to update a row in the database? thank you.

deladels started a new conversation Extracting Values From Url And Updating Table In Db • 2 weeks ago

so using route model binding i am able to get this url : http://127.0.0.1:8000/schedule/1 is there anyway i can extract the id which in this case is one and insert it into a table in a database?

as at now this is what i have which is not working:

class BookingsController extends Controller {

//NB: i am passing/getting $schedule from the url, sort of
    public function getScheduleId($schedule){

        $booking = new Booking;

        $booking->schedule_id = $schedule;

        $booking->save();

}

public function store(){

    $this->validate( request(), [

            'lastName'      => 'required',
        'firstName'     => 'required',
        'email'         => 'required',
        'mobilenumber'  => 'required',
        'additionalId'  => 'required',
        'idNumber'      => 'required'

    ]);

    Booking::create([

        'schedule_id'           => request($schedule),
        'lastname'      => request('lastName'),
        'firstname'     => request('firstName'),
        'email'         => request('email'),
        'mobilenumber'  => request('mobilenumber'),
        'id_type'           => request('additionalId'),
        'id_number'     => request('idNumber')


    ]);
    
}

}

5th January, 2018

deladels left a reply on Accesing Values From Another Model • 2 weeks ago

so like you said @bobbybouwmann i have set up the relationships. now, i want to pass the From: Accra value and To values to my bookings controller in other to insert into my bookings table. how do i do that?

4th January, 2018

deladels left a reply on Accesing Values From Another Model • 2 weeks ago

Alright i'd do that. Thanks very much @bobbybouwmann

deladels left a reply on Accesing Values From Another Model • 2 weeks ago

how do i connect them? through relationships?

so a user is able to book a particular schedule. i want to update the bookings table with the particular schedule the users book i"ll then like to display the respective values of booking on the payment iew page.

i dont know if i am making myself clear tho. THanks

deladels started a new conversation Accesing Values From Another Model • 2 weeks ago

i am trying to access values that reside in a controller within another controller. i used route model binding to route to specific schedule.

now i want to retrieve the schedule id or the schedule parameters in a bookingsController. how do i go about it?

this is how the page looks like https://imgur.com/a/Yy42d

my bookingscontroller.php

namespace App\Http\Controllers;

use App\Http\Controllers\Controllers;

use Illuminate\Http\Request;

use App\Booking;

use App\Schedule;

class BookingsController extends Controller {

public function store(){

    $schedule = new Schedule;

    $schedule = Schedule::find($id);

    $this->validate( request(), [

        'lastName'      => 'required',
        'firstName'     => 'required',
        'email'         => 'required',
        'mobilenumber'  => 'required',
        'additionalId'  => 'required',
        'idNumber'      => 'required'

    ]);
    dd(request()->all());
    dd(request($schedule->departure_location));

}

}

3rd January, 2018

deladels left a reply on Suggestions On A How To Carry Out A Particular Task. • 2 weeks ago

thank you so much @xmarks for your beautiful insights. @shez1983 thank you too. I'll try and see if i can add that. higher score is definitely a go for

29th December, 2017

deladels left a reply on Suggestions On A How To Carry Out A Particular Task. • 3 weeks ago

maybe not necessary. just trying to make it more fancy and flexible. the logic is what i am trying to figure out.

the bus service is from one destination to another, kind of traveling distance. it doesnt go around town.

28th December, 2017

deladels started a new conversation Suggestions On A How To Carry Out A Particular Task. • 3 weeks ago

so i am working on a bus reservation system for my final year project in school. its not so huge.

now i am kinda caught up in a situation. i will want to allow users to select or book a particular seat in a bus, preferable via a select/drop down. is this advisable? if yes, i have been trying to sketch things but i cant seem to figure out how to go about it. any suggestions please?

23rd December, 2017

deladels started a new conversation Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No Message • 4 weeks ago

i am trying to post data to my database. on submission of the form i get the error and i can seem to figure it out:

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No message

this is my route:

Route::post('/addBus', '[email protected]');

my model:

namespace App;

use Illuminate\Database\Eloquent\Model;

class AddBus extends Model {

protected $fillable = [ 'reg_number', 'model', 'capacity' ];

}

controller:

namespace App\Http\Controllers;

use App\Http\Controllers\Controllers;

use Illuminate\Http\Request;

use App\AddBus;

class BusesController extends Controller { //metthod to store buses public function store(){

    $this->validate( request(), [

        'busRegNo'  => 'required',
        'busModel'  => 'required',
        'capacity'  => 'required'

    ]);

    dd(request()->all());

    AddBus::create([

    'reg_number'  => request('busRegNo'),
    'model'       => request('busModel'),
    'capacity'    => request('capacity')

]);

return back();
}

}

22nd December, 2017

deladels left a reply on Trying To Get Property Of Non-object • 4 weeks ago

oh okay. thank you very much @tykus for your vivid explanation since i am new to laravel. and it worked perfectly.

deladels started a new conversation Trying To Get Property Of Non-object • 4 weeks ago

i am trying to display data from my database. i am using laravel's blade templates when i load the page, i get the error below.

Trying to get property of non-object (View: C:\xampp\htdocs\BusTravel\resources\views\schedule.blade.php)

blade/html file:

FROM TO DATE DEPARTURE TIME BUS PRICE
        @foreach ($schedules as $schedule)
            <tr>
                <td>{{ $schedule->departure_location }}</td>
                <td>{{ $schedule->destination_location }}</td>
                <td>{{ $schedule->departure_date    }}</td>
                <td>{{ $schedule->departure_time }}</td>
                <td>{{ $schedule->bus}}</td>
                <td>{{ $schedule->price}}</td>
            </tr>
        @endforeach
    </tbody>
</table>

function in controller to get all schedules:

public function show(Schedule $schedules){

    return view('schedule', compact('schedules'));
}

route:

Route::get('/schedule', '[email protected]');

21st December, 2017

deladels left a reply on SQLSTATE[22007]: Invalid Datetime Format: 1292 Incorrect Datetime Value: '07:30PM' For Column 'departure_time' At Row • 1 month ago

i changed the type to $table->time('departure_time) and got this error

SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect time value: '07:31PM' for column 'departure_time' at row 1

Edit Your Profile
Update

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